- Jan 15, 2001
- 15,065
- 90
- 91
I searched before I posted and only found 1 thread with no answers.
I am trying to write a C++ application to control a circuit I designed over a COM port. Actually, I would very much prefer to use USB but I don't know how to use the USB functions provided in the DLL for the IC I designed into my circuit, so I am just using it as a VCP. Anyway, I completely understand how it is supposed to work so theory isn't my problem here.
I've been searching google for hours and I've found basically nothing helpful. I know I can do this using write/read directly but I want to do it the "right" way. I found some code earlier today that I scrutinized in order to understand it and it talked about creating a process for reading and writing so neither blocks the other. That makes sense but I don't know how to write these kinds of programs in Windows. The Windows libraries confuse me.
Here are the facts about my circuit:
Right now I simply have the UART RX interrupt sending every value it gets back to the sender immediately as a way to "loopback" and test the communication. I've done this a billion times and I knew it would work ahead of time, but I don't know how to get that into something usable in C++.
The circuit is measuring acceleration in 3 dimensions 20 times per second and needs to send these values to a PC where they will be stored in a file that can be imported into Excel. I will also need to send commands to it based on the values it is sending me. I know none of this is very complicated, but like I said, my problem is what to actually write in my program to make this happen. I want a clean solution (80% to learn, 20% to solve this problem) and everything I've found on google has been either way too complicated for a beginner or simply doesn't work (i.e. deprecated headers are needed, written for linux, etc.).
If someone is willing to help me with this I would really appreciate it. Here is basically what I want the program to be able to do (I'm not asking someone to write the whole thing for me - just to show me where to start and give me some guidance):
-send a command to start measuring accelerations
-receive 60 data points per second and write them to a file until i type 'q' for quit
-while it is receiving data points, send commands typed by the user to change settings in the MCU
I would prefer being able to set the BAUD and format but if I simply have to use the pre-defined settings in Device Manager -> Ports then so be it.
Edit: To clarify the rate at which data points will be received - this has nothing to do with the computer. I'm saying the MCU will take a reading of each axis every 50mS, so the data will really be sent to the computer every 50mS. I know these will be read into a buffer by the PC.
Edit 2: I found this webpage explaining how to do it, but this is exactly what I was talking about before. I read every word of that webpage and I understand what it is talking about, but I don't get how to do it in C++. I'm not familiar enough with multithreading applications to actually write one or even how to get it to compile with the right headers and libraries. That is what I need help with.
I am trying to write a C++ application to control a circuit I designed over a COM port. Actually, I would very much prefer to use USB but I don't know how to use the USB functions provided in the DLL for the IC I designed into my circuit, so I am just using it as a VCP. Anyway, I completely understand how it is supposed to work so theory isn't my problem here.
I've been searching google for hours and I've found basically nothing helpful. I know I can do this using write/read directly but I want to do it the "right" way. I found some code earlier today that I scrutinized in order to understand it and it talked about creating a process for reading and writing so neither blocks the other. That makes sense but I don't know how to write these kinds of programs in Windows. The Windows libraries confuse me.
Here are the facts about my circuit:
Right now I simply have the UART RX interrupt sending every value it gets back to the sender immediately as a way to "loopback" and test the communication. I've done this a billion times and I knew it would work ahead of time, but I don't know how to get that into something usable in C++.
The circuit is measuring acceleration in 3 dimensions 20 times per second and needs to send these values to a PC where they will be stored in a file that can be imported into Excel. I will also need to send commands to it based on the values it is sending me. I know none of this is very complicated, but like I said, my problem is what to actually write in my program to make this happen. I want a clean solution (80% to learn, 20% to solve this problem) and everything I've found on google has been either way too complicated for a beginner or simply doesn't work (i.e. deprecated headers are needed, written for linux, etc.).
If someone is willing to help me with this I would really appreciate it. Here is basically what I want the program to be able to do (I'm not asking someone to write the whole thing for me - just to show me where to start and give me some guidance):
-send a command to start measuring accelerations
-receive 60 data points per second and write them to a file until i type 'q' for quit
-while it is receiving data points, send commands typed by the user to change settings in the MCU
I would prefer being able to set the BAUD and format but if I simply have to use the pre-defined settings in Device Manager -> Ports then so be it.
Edit: To clarify the rate at which data points will be received - this has nothing to do with the computer. I'm saying the MCU will take a reading of each axis every 50mS, so the data will really be sent to the computer every 50mS. I know these will be read into a buffer by the PC.
Edit 2: I found this webpage explaining how to do it, but this is exactly what I was talking about before. I read every word of that webpage and I understand what it is talking about, but I don't get how to do it in C++. I'm not familiar enough with multithreading applications to actually write one or even how to get it to compile with the right headers and libraries. That is what I need help with.