OK! I think I figure out why the cpp implementation seems have weird result…
To finish this topics, I would like to share my storyline to you great guys:
-
First of first, I want to send image and some logdata to PC in real time, so I test Example USB_VCP.py and it works fine and fast, as stated in previous post, it can reach 1MB/s.
-
But my project is in cpp language, so I have to implement the USB_VCP.py into cpp.
-
Here is the thing where I got wrong, I had consider USB_VCP is something like UART(which is not). Because in my previous thought, if something need to set baudrate and with ‘Serial’ name, it would be UART
.
-
So I keep coding as communication using UART in ROS, using ROS Serial package. It actually worked and I got what I want(mentioned in my first post above), but the data rate is confusing.
-
In days I keep checking the configuration of Serial Port code, no result. I think it is because the ROS Serial package can not meet my needs.
-
I rethink the whole thing and I found I shouldn’t have considered USB_VCP as UART, but USB. So treat it as a normal USB port may helps.
-
then I found this post: Sending serial data out (via USB) with C++
the cpp class in this post finally have the same function of USB_VCP.py
which means: the transmit rate reach 1MB/s stably, and the boadrate setting is invalid.
I think openmv-RPC have some similar work to send data and images to PC, wait to see, but I doubt it have a friendly interface with cpp, too.
thanks you guys.