Assuming this is a binary data stream, this sounds like a classic VMIN/VTIME
issue on the read.  I would try  adjusting the read and VMIN to max packet
size and VTIME to 50% of the transmission interval to read packets.  If the
interval is not known, you have to set it higher than the max
inter-character delay time allowed by the senderThe only option I know is to
do 1 char reads and do the packet assembly and checking yourself.

> -----Original Message-----
> From: Jean-Marie Bussat [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, May 18, 2000 4:48 AM
> To:   [EMAIL PROTECTED]
> Subject:      Reading to serial ports
> 
> 
> Hello,
> 
> I would like to read data comming from two serial port as soon
> as they arrive.
> 
> I have two devices, one connected to each port. They are sending
> data packets sequentially. E.g. device A send one packet then
> device B send its packet and so on. Packets can have any length
> going from 1 to 30 bytes.
> The serial lines have a speed of 4800 baud and packets are
> roughly sent every second.
> 
> I would like to read packet as they are sent and I want to see
> them in the same order they were sent.
> 
> Currently, I've written a C program which make use of "select"
> to achieve that. The problem is that it is not working in all
> conditions.
> If packets contain less than 2 bytes and if they arrive slowly,
> this is working well. But, if I set the packet sending speed
> to one every second, it seems to me that what I'm reading is
> only related to the size of the receiving fifo. I'm seeing
> packets but they are broken :
> 
> data from device A   |   data from device B
> --------------------------------------------
> <packet 1A>          |                       \
>                      | <packet 1B>            |what I expect and
> <packet 2A>          |                        |would like to see
>                      | <packet 2B>           /
> 
> ============================================
> 
> <begining of         |                       \
> packet 1A>           |                        |
>                      | <packet 1B>            |
> <end of 1A +         |                        |what I'm getting
> begining of 2A>      |                        |
>                      | <begining of 2B>       |
> <end of 2A>          |                        |
>                      | <end of 2B>           /
> 
> I've read in the serial-HOWTO that "select" might not be the
> most appropriate function to use but I have no idea of another
> alternative (I'm writing programs from time to time when it is
> required by my job but this is not my primary occupation - so,
> I'm lacking some knowledge about the programming API of the
> Linux kernel).
> 
> Does anybody have an idea about how to do what seemed to me
> a simple task (at the begining) ? Or does anybody have any
> pointer/links to something that should do this job ?
> 
> Thanks in advance for any answer.
> Best regards,
>       Jean-Marie 
> -- 
>  +------------------------------------------------------------+
>  | Jean-Marie Bussat - Dept. of physics, Princeton University |
>  | CERN/EP - Bldg. 15-S-012 - CH-1211 GENEVA 23 - Switzerland |
>  | Email: [EMAIL PROTECTED]                                      |
>  | Tel: (41 22) 767 32 41              Fax: (41 22) 767 32 41 |
>  +------------------------------------------------------------+
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-serial" in
> the body of a message to [EMAIL PROTECTED]

-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [EMAIL PROTECTED]

Reply via email to