Serial Write single character

Good morning (o;

Have a grblHAL board here I would like to talk to and control it or shows its parameters and positions.

Now grbl uses the character “?” to display actual position besides other information.

Now when I use:

SerialConnection1.Write("?")

The DataReceived event is never fired…

Also adding after a

SerialConnection1.Flush

Doesn’t trigger it.

Am I missing something simple here? (o;

Seems it is just not possible to do so…

Doc for SerialConnection says though:

Flush
Immediately sends the contents of internal write buffers to disk or to the output stream.

But no effect on macOS and Linux…checked with two FTDI USBserial adapters back to back.

File an issue? But then I can’t wait for a fix that long (o;

Okay…sending out a single “?” character works…

Still what is odd that DataReceived never fires as the actual data is sent back as soon I type “?” in the macOS Serial app when connected to the controller.

Have to grab a grbl board that use an USB to UART converter as this one uses USB CDC, which is hard to show the signals on my scopes (o;

Can you show us the code that you are using to send the character?

Well sending the single character works…

Just a simple:

SerialConnection1.Write("?")
SerialConnection1.Flush

Seems to be an issue with specific GRBL boards using USB CDC and how they handle “?” command…

Sending a “!” to stop movements immediately works, which is odd…have to check other special single characters.

Opened a github issue at the developer…

Is this in a desktop app? Console? Are you giving the socket a chance to poll?

Hi Richard, do you need to terminate a line with a CR or CRLF (not sure if the device you’re sending ‘to’ requires a termination character)

There are two different types of commands for GRBL CNC controller…

General commands are terminated with CR/LF
and there are immediate commands that can be sent when the motors are moving, for example…like status report (current position, limit switch status, speed, feedrate) and stop/hold commands…those are all single characters without line termination.

I suspect it has something to do with USB CDC as all other boards with USB2UART converters are fine…downside is…you don’t see what is happening with USB CDC except you have a debug port on the target.

Gonna grab out some STM32 Nucleo boards with USB ports and see with a debugger what is happening…

I’ve forwarded my test code to the developer in charge for the GRBL STM32 controller.

The developer found the problem:

DTR wasn’t being asserted on the USB-CDC connection from the Xojo app, and was therefore failing a connection check before sending the status response. Not sure why that doesn’t affect more output, but hey ho…

Looking at your code, I tried setting SerialConnection1.DTR = True, but no change. Then google led me to SerialConnection1.DataTerminalReady = True, and that seems to have done the trick here.

That’s why it didn’t worked for me as I tried SerialConnection.DTR = True as well.

D’ye need to set it before opening the connection? Or is that what you’re doing.

Had it before .Connect as the docs say so…any change in CTS/DTR requires to reopen the connection.

Stupid me…got DTR and DataTerminalReady mixed up, one setting flow control, the other setting the line state (o;

First test runs nicely now with grblHAL STM32H723 board. Entering a move command updates the coordinates display nicely (o;