C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 05-30-2009, 03:03 AM   #1
Registered User
 
Join Date: May 2009
Posts: 2
Duplex communication thro serial port

Hi,

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   Reply With Quote
Old 05-30-2009, 04:24 AM   #2
and the hat of Jobseeking
 
Salem's Avatar
 
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.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 08:04 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22