• Post Reply Bookmark Topic Watch Topic
  • New Topic

Serial port question  RSS feed

Pradeep Kumar T
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an app in which I need to communicate some data( an int array ) over a serial port connection. The way I need to do this is first send the first item of data and then wait for an echo from the device connected to the serial port and then send the subsequent items of data.
So each item of data will be sent as a response to an echo received from the device.
The way I am doing this now I have the serial port implement the SerialPortEventListener interface and use the serialevent() method in the interface to listen to serial events of type DATA_AVAILABLE. Once I receive this event, I write an item of data to the serial and then wait for the DATA_AVAILABLE event once again. This works fine sometimes, but a lot of the time the SerialEvent is either not trigerred or is somehow missed and the serialevent() method is simply not called. My program send the first item of data and just stops.
What exactly am I doing worng? The device that I am sending data to is supposed to be echoing back the data within 5ms. Should I have the data sending code operating in a separate thread or do I need to use Thread.sleep() to wait for the serial event to be generated. I have tried all of those things, but they do not seem to work.
Please advice!
Thanks a lot in advance!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!