CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

rs232 odd length strings

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
delene
Guest







rs232 odd length strings
PostPosted: Thu Jul 24, 2003 8:17 am     Reply with quote

I am using ISR to receive data in through the rs232 port. My problem is that the strings that i am receiving are NOT fixed length. Some are 8 characters and others 11. there is no start of message, or end of message. Any suggestions on how I capture the full string

Thanks
Delene
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516311
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: rs232 odd length strings
PostPosted: Thu Jul 24, 2003 9:11 am     Reply with quote

<font face="Courier New" size=-1>:=I am using ISR to receive data in through the rs232 port. My problem is that the strings that i am receiving are NOT fixed length. Some are 8 characters and others 11. there is no start of message, or end of message. Any suggestions on how I capture the full string
#int_TIMER1 //*********************************
TIMER1_isr() // 1.5 byte periods after last byte
{ disable_interrupts(int_TIMER1); // TMR1 Overflow Interrupt Enable bit off
--PacketIndex; // Set index to last recieved byte
CommPacketIn=1; // Tag packet for processing
}
#int_RDA //**************
RDA_isr() // BYTE RECIEVED
{ int8 x; // Create byte storage
x = fgetC( chanA ); // Get incomming byte from buffer
if(!CommPacketIn) // Do not accept incomming bytes if packet is waiting
{ PacketBuffer[PacketIndex++] = x; // Place incomming byte in PacketBuffer
if( bit_test(PacketIndex,6)) // If packet index larger than packetbuffer (64)
PacketIndex = 0; // Zero packet index value
set_timer1( 48640 ); // Wait 1.5 byte periods then interupt (set for 4800bps now) EVALUATE FOR PERFORMANCE
TMR1IF=0; // Clear timer1 overflow Interrupt Flag bit
enable_interrupts(int_TIMER1); // TMR1 Overflow Interrupt Enable bit on
}
}
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516312
Levett Prins
Guest







Re: rs232 odd length strings
PostPosted: Sat Jul 26, 2003 3:51 am     Reply with quote

:=I am using ISR to receive data in through the rs232 port. My problem is that the strings that i am receiving are NOT fixed length. Some are 8 characters and others 11. there is no start of message, or end of message. Any suggestions on how I capture the full string
:=
:=Thanks
:=Delene

The most succesful method I used so far is to simply wait for a timeout condition and then to process the RX buffer. I am using it to read variable length strings from a modem. Change the timeout length according to the baud rate you are using.

Good luck

Levett


#INT_RDA
void RDA_isr()
{
long timeout=0;
char c;

c=fgetc(MODEM); RXbuffer[RXi]=c;

while(!kbhit() && (++timeout<5000)) // wag vir volgende karakter
{delay_us(10); if(kbhit()) break;} // 19200BPS = 2ms / CHAR (50000 = 500 ms)

if(timeout>=5000) //end of response
{
RXi_END=RXi; //end of line index
//**PROCESS RXbuffer HERE!!!
RXi=RXbuffer_LEN_LOD; //cause overflow to clear and reset RXbuffer
}
RXi++;
if(RXi>=64) //prevent overflow
{
for(RXi=0; RXi RXi=0;
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516385
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group