![]() |
| | #1 |
| Registered User Join Date: May 2009
Posts: 2
| Duplex communication thro serial port I am writing an application in C on a Beagleboard (running Ubuntu) which reads sound samples from a microphone (using ALSA APIs), compresses them and writes it to the serial port to a radio (which broadcasts it). For duplex communication, i need to receive the data from the radio (by reading from the serial port), uncompress it and send it to the speaker (again through ALSA APIs). The problem here is that the whole operation is performed in a loop. I am writing byte by byte into the port and sending it to the radio. However the radio writes 80 bytes as and when it receives a packet and there is no synchronization between the two devices. Effectively i am unable to read any data from the serial port. Can anyone suggest a better method of implementation ? Thanks in advance, Priya. |
| Priyachu is offline | |
| | #2 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,680
| Put the serial port into non-blocking mode - any read() will either return with an error of EAGAIN or some data. Use select() to determine if there is any data before trying to read it. Select has many wonderful features, read all about it in a manual near you. |
| Salem is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Duplex communication thro serial port | Priyachu | Linux Programming | 1 | 05-30-2009 04:03 AM |
| Serial port Communication | vin_pll | C++ Programming | 23 | 01-07-2009 09:32 AM |
| Serial Port Communication | maxorator | C++ Programming | 11 | 04-27-2006 03:13 PM |
| DOS, Serial, and Touch Screen | jon_nc17 | A Brief History of Cprogramming.com | 0 | 01-08-2003 04:59 PM |
| Need help or info about serial port communication | Unregistered | Linux Programming | 1 | 01-08-2002 01:48 PM |