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,