I have been browsing the web and looking at existing topics, but I’v had no luck.
I am trying to read data via USB from an Arduino Nano. I can’t seem to find any simple serial reading examples. All I am trying to do at present is read the USB serial and dump it into a textfield. Eventually, I want to parse the data, but that is pointless if I can’t even get a TextField dump.
- Do I have to somehow specify I am using the USB? Or is that automatically assumed?
- Yes, I set both interfaces at 9600 baud
- Using Serial.ReadAll puts nothing in my TextField using the DataAvailable Event
This should be so simple. Can anyone lead me in the right direction?
did you open the right usb port ?
do you see your usb-serial adapter in one of the available system.serialport ?
I set the port using
Serial1.SerialPort = System.SerialPort("/dev/cu.wchusbserial1420")
And still nothing. I get blank data every time I Serial1.ReadAll and I am getting no errors. I was expecting my TextField to be inundated with data of some type.
Also, say I have multiple USB devices, a printer, a mouse receiver, and arduino. How does XOJO know which USB to read the data from?
Any other ideas?
There is an example in Communication -> Serial -> Serial Port Bar Code Reader Example, that i think must work for that test.
If you can read it with a normal serial terminal, you can most certainly read it in Xojo. Do you have some example code? This lines probably means you are on a Mac: “Serial1.SerialPort = System.SerialPort("/dev/cu.wchusbserial1420")”. Google shows some issues with this Chinese USB-serial device on some systems. Once you program your device via Arduino, do you exit the Arduino IDE before trying to connect with Xojo?
There are quite a few threads about serial. Below are just a couple samples: