June 8th, 1999, 11:42 PM
I am using a thread to read serial data from Com2. The data is coming from a device which sends a packet of 25chars every 4ms.
Is it reasonable to send a message from my comm thread to the dialog thread when I have decoded every packet, or would a message
every 4 ms be too fast for the dialog box to handle. My function in the dialog box just does a sprintf of the 25 bytes and displays the hex chars.
Also, can I assume that in my comm thread that an entire function will be completed without being context switched in the middle of processing?
For instance, in my comm thread I am using a simple state machine whic determines the start and end of the packet and places the
packet in it's own 25 character array. There are 8 discrete packets so I essentially have an array of character arrays, ie:
struct PACKET{
char DataBytes[25];
other data members;
...
...
};
PACKET Packet[8];
My state machine simple looks for the first two characters, then places the rest of the data in it's respective character position in it's
respective array of Packet(s). The point I'm getting at is this, if I am in the middle of my state machine could a context switch essentially interrupt
this process causing me to lose characters from the serial port (which come in 25 every 86us followed by a 4ms delay, then 25 every 86us...)
I have written a debug which places the data in a buffer as soon as it is read from the port and that works fine. Do I possibly just
have to dump my serial data into a huge buffer when it is read, then use another thread to parse it into the respective array of structures?
This seems like a lot of work. Follow this link to see some screen shots of what I'm doing...
http://www.cyberg8t.com/rminnig/VIPER/ss.jpg
Thanks
Is it reasonable to send a message from my comm thread to the dialog thread when I have decoded every packet, or would a message
every 4 ms be too fast for the dialog box to handle. My function in the dialog box just does a sprintf of the 25 bytes and displays the hex chars.
Also, can I assume that in my comm thread that an entire function will be completed without being context switched in the middle of processing?
For instance, in my comm thread I am using a simple state machine whic determines the start and end of the packet and places the
packet in it's own 25 character array. There are 8 discrete packets so I essentially have an array of character arrays, ie:
struct PACKET{
char DataBytes[25];
other data members;
...
...
};
PACKET Packet[8];
My state machine simple looks for the first two characters, then places the rest of the data in it's respective character position in it's
respective array of Packet(s). The point I'm getting at is this, if I am in the middle of my state machine could a context switch essentially interrupt
this process causing me to lose characters from the serial port (which come in 25 every 86us followed by a 4ms delay, then 25 every 86us...)
I have written a debug which places the data in a buffer as soon as it is read from the port and that works fine. Do I possibly just
have to dump my serial data into a huge buffer when it is read, then use another thread to parse it into the respective array of structures?
This seems like a lot of work. Follow this link to see some screen shots of what I'm doing...
http://www.cyberg8t.com/rminnig/VIPER/ss.jpg
Thanks