I am playing with the Firmata protocol which allows you to control Arduino through a serial protocol. I am reading sensor values using SerialPortEventListener listening for DATA_AVAILABLE event. But i notice a lot of latency it takes a second for the updated sensor values to be registered by my application, protocol runs at a baud rate of 57600. My question is does the event listener run on a separate thread or does both my application and listener run in the same thread and my application slow things down.
EDIT: To make my self clear, i am just asking in theory would it be faster to read serial transmission in a separate thread or using the event listener?
Sorry about all these answers, I'm thinking hard about your problem.
Apart from the problem of updating your GUI from the wrong thread, the issue of threads is probably pretty irrelevant. Since getting an update from your serial port probably doesn't consume a lot of CPU power (it shouldn't, anyway, unless it's done with a tight polling loop) there will not be any noticeable contention for CPU resources between your threads, and so there should be no possibility for threads to be "slowing each other down." I'd pretty much discount this possibility. But you could look in TaskManager (Windows) or System Monitor (Linux) to see if your CPUs are being kept really busy; that might change things.