Electronic – arduino – Connect to Arduino Mega serial interface by C code

arduinoserial

I'm having trouble talking to an Arduino Mega using serial port commands on Windows. Identical code works fine to connect to an Arduino Duemilanove but doesn't allow connection to the serial port with the Mega. Also, I can access both cards from the Arduino IDE software, on both Linux and Windows.

I have serial port code that works fine on Linux for both Duemilanove and Mega. But I can't write code that works for the Mega on Windows, even though it works fine with the Duemilanove at this stage.

My only thought is that perhaps something is different in the way that the Mega's USB-to-serial hardware is set up, and perhaps, at least on Windows, I need to add some additional command (maybe on the Arduino, or maybe in my C code) to enable the interface to be correctly visible/accessible.

Any thoughts anyone? Anyone else had this problem?

Best Answer

This sounds like you might be having a baud rate mismatch. I have seen many cases where a device or library will default to a particular baud rate and wont be an issue until switching devices or platforms.

The other possibility is using a serial class that only works on linux.