I am trying to read some data from an Arduino serial port. The Arduino simply transmits a bunch of ASCII characters. On the XOJO side, I used a slightly modified version of the BarCode Reader example code. Here is what happens.
I can see and connect to the Arduino serial port just fine from XOJO, but…
When using an Arduino Uno board all the characters are read and displayed just fine
when using an Arduino M0 or M4 express board no characters are read by the XOJO program.
CLUES:
the M0 and M4 boards will write to the Arduino IDE Serial Monitor just fine, as does the Arduino Uno board
The M0 and M4 boards use a different micro (SAMD51 v.s. AMD)
I tried adding a button to Xojo code that sets SerialConnect.CTS=true and SerialConnect.reset, but that made no difference
if I disconnect the serial port from XoJo and switch to the IDE Serial monitor, the Arduino serial buffer is dumped to the Serial monitor and I can see all the characters
Perhaps the on the M0/M4 the ports on the device are not being interpreted as a “Serial” device. Maybe create a listbox and populate with the COM serial ports which each device plugged in (separately).
In a button:
lbxSerialPorts.DeleteAllRows
Dim count As Integer
count = System.SerialPortCount
For i As Integer = 0 To count - 1
lbxSerialPorts.AddRow(System.SerialPort(i).Name)
lbxSerialPorts.RowTag(lbxSerialPorts.LastIndex) = Str(i)
Next
There is a TX and RX light on the Metro M0 Express. When I send data to the serial port from Xojo the RX lights up. When the Arduino is supposed to send data to Xojo, the TX does not light up. Do I have some kind of handshaking problem here?
TX lights up when connected to the Arduino IDE serial monitor and sending…
Arduino UNO works at 5V, the M0 works at 3.3V. Oh I see that you are talking about the Metro M0 Express - it’s not the same board - this one works at 3.3 V.
On which computer are you running the Xojo application ?
run-in xojo app on same computer the board is plugged into- my mac.
ANOTHER BIG CLUE: using terminal and running “screen” I was able to connect to the arduino serial port and read/write to it. both the TX and RX lights were responding, and I had the Arduino echoing characters back to the terminal.
So there is something about the Xojo connection that is wonky.
Seems like maybe some confusion as to which device is DTE and which is DCE - they might both be trying to be DTE. Can you tell the Arduino that it’s a peripheral, i.e. DCE? Also, enabling DTR in Xojo maybe doesn’t necessarily set the DataTerminalReady line to a receptive state (although you’d think it would) - you could try manually setting DataTerminalReady property, although the Xojo docs don’t tell you whether the boolean means the output is high or low (low generally being “active” in RS-232).
I would first try this, set all the connection parameters in code.
If that doesn’t work, I would check the feedback system for known bugs in the Serial and SerialConnection classes (Serial was tha API1 name, right?).
Also, you could create a SerialConnection testing app that allows you to try different connection parameters quicker, something like this but adapted to your needs (this is an old project, API1, no way to change RTS/DTR/CTS while running): Dropbox - COMCheck.rbp - Simplify your life
NOTE: at least part of the code in that project is not mine, I probably got it from the example files or forum posts (I can’t remember anymore).