I’m trying to create a program where the user enter a string which can be encoded to a message and sent (via USB) to my Arduino board, which receives the message and displays it on the LCD screen. I’ve got the Arduino side of things all-but-working: I can send a string via the serial monitor in the Arduino IDE (complete with flag values to mark the start and end).
My issue now is in creating the program to drive it. I’ve never tried to connect to a serial connection via C++. I’ve been looking at a few different implementations this afternoon but I’m having difficulty sorting between them and finding, at least for me, the easiest to use.
I feel that my needs are fairly modest, in that I’m essentially creating a console application with a loop-driven menu system that will ask the user what they want the next string to be and then encoding that into a new string and sending that.
I’ve seen a few different posts that involve using the SerialPort class/library in CLR C++, but I have no experience in CLR C++, and it does appear somewhat different. Would it seem to be particularly difficult for someone with decent native C++ knowledge (I’m just completing my second C++ class on data structures and OOP, which is what this project is actually for) to move to CLR C++ quickly or is there a better alternative out there?
The best I could find otherwise was on this page: http://arduino.cc/playground/Interfacing/CPPWindows, however, when I tried adding the header and CPP files to my native project in Visual Studio, I got an error on compile: error C2664: 'CreateFileW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'. Does anyone know if I can use this in that type of project or not?
Thanks for your help! I’m just rather confused on where to proceed with this project.
I think CLR is not necessary. Sample class which You’ve provided should be sufficient, and problem You’ve pointed can be solved using casting, e.g.
There are two modifications: changed macro CreateFile to function CreateFileA, and static_cast the first param. If still in problem, try to add some more specific questions.