hello and good day to you guys. I am running Windows XP which I am given to understand is a 32 bit windows system.
I have a microcontroller that continuously sends dat开发者_如何学JAVAa serially through a COM port. I want to process data in a C program. The options I'm looking at so far are:
- get serial data via python and pass to C
- read data serially and use in C
The first option seems too hard for me. I was trying to use swig and am stuck. any other suggestions?
You'll find it much easier just to receive the data straight via C, if you're going to process it there in the end anyway. Here's a quick overview of how to set things up. Essentially you call CreateFile
on, eg, "COM1"
, then use GetCommState
and SetCommState
on the resulting handle to configure the port. If you need to do GUI interaction as well, have the reading code run on a different thread, and communicate the data it reads back to the GUI thread by posting custom (WM_USER
, etc) messages to one of your windows.
精彩评论