ev3rt-git / ev3rt-hrp2

RTOS for Mindstorms EV3
http://ev3rt-git.github.io
GNU General Public License v2.0
22 stars 16 forks source link

USB CDC Support #8

Open oscartbeaumont opened 5 years ago

oscartbeaumont commented 5 years ago

Hello, I have been looking into using ev3rt for Robotics competition I compete in. It is nice but there are still a few things that make it hard for me to adopt for the comp as I need to be able to move really quickly during the competition day/s. I think adding support for USB CDC would be better than using USB MSC because it would allow the software to preview sensor data on the host computer, download the programs while the UI is showing or other programs are running and also allow for a download and run feature like the official EV3 software is able to. I would be willing to build the protocol for the communication and get it working but I have been unsuccessful at implementing USB CDC. I was thinking of developing a VSCode extension to communicate over this protocol and compile the code ready for the robot. I have very limited knowledge about bare metal operating systems are drivers like this so have been finding it difficult. I would be interested in learning but have been unable to find information online to help. This may even be better as a fork or alternative version than on the official version but I would be interested in if others would find this useful and be able to help get it working.

YixiaoLi commented 5 years ago

Hello, The obstacle to add USB CDC is that you have to implement drivers for both EV3 and host OS (e.g. Linux/macOS/Win10).

it would allow the software to preview sensor data on the host computer, download the programs while the UI is showing or other programs are running and also allow for a download and run feature

You can use Bluetooth to send sensor data to the host and upload programs. Could you tell me why you want to use USB instead of Bluetooth?

oscartbeaumont commented 5 years ago

In regards to each OS, my idea was a VScode extension which if tested correctly would allow for cross platform code with Nodejs. I think this feature would more be more in addition to the MSC mode. I would be able to develop the protocol on both the EV3 and host side but implementing a bare-metal driver for CDC is out of my understanding (even though I would love to learn I just don't know how). My original plan was to create a fork and add it but I have spent a few days and haven't got anything working. I saw that the usblib library looks to have code for handling CDC although I don't know if it is working as the README reports MSC to be the only working mode. The competitions I compete in basically requires the use of USB as Bluetooth causes an incredible headache with interference. There is a very large density of Bluetooth devices in a single room. I love Bluetooth, I use it while preparing for the comp but it just can't be used on the day. I will also look into implementing the features I want using Bluetooth but I will still need USB support for me to adopt it. As a side note to show the unusability of wireless in the venue, the national competition last year used a Wifi based scoring system with tablets. They had to shut down power to the competitor areas to try and isolate the cause of the interference and they had to ban wireless communications. The Mindstorms software freezes for a good minute when you try and reload the Bluetooth section as well. EDIT: If I built this I would implement it both for Bluetooth and USB with the same protocol.

YixiaoLi commented 5 years ago

The competitions I compete in basically requires the use of USB as Bluetooth causes an incredible headache with interference.

I see. I will try to add CDC but am not sure how much time it may take. The CDC driver under usblib should work but is never tested. (You can find some information here.)

BTW, you can also use a sensor port for serial communication (e.g. http://www.mindsensors.com/ev3-and-nxt/40-console-adapter-for-ev3), although it is a bit slow.

oscartbeaumont commented 5 years ago

Thanks so much for giving it a shot. Keep me posted with progress.

YixiaoLi commented 5 years ago

I have added experimental support for USB CDC. It can be used for testing purposes, although the performance and robustness need improvement.

Edit rc.conf.ini as follows to use CDC mode.

[USB]
Mode=CDC

oscartbeaumont commented 5 years ago

Awesome. Thank you so much. Expect a PR hopefully over the next week or so with a working protocol for the features I wanted.

JarekParal commented 4 years ago

@oscartbeaumont Do you have some progress?

oscartbeaumont commented 4 years ago

I haven't made any useful progress as I was way out of my depth (I struggle to understand OS and low-level programming) and I couldn't find may resource to help me understand what I was doing. I am currently trialling non-ev3 robots so I probably won't finish it but I would definitely help out if I could cause I am still interested in making this project better and having it working as a backup in case my current plans fail.