I’ve got a USB device that is presenting a virtual serial port on my windows machine. Normal stuff. COM9 in my setup
If I open it with TeraTerm, 9600,8,N,1 no flow control, I get bidirectional communications without problems. The device is spitting out a couple of bytes with a CRLF at the end of it 2/second so this isn’t exactly fast or rocket science stuff. I see all this traffic with TeraTerm without problems.
Using the serial port example in Xojo 2018R4 that is looking for CRLF lines coming back from a barcode reader and putting them on the screen (sorry, wasn’t paying enough attention when I opened it as to what the name of it was, but it was under the communications dropdown of examples):
I connect to COM9 (9600,8,N,1 no flow) with no errors given
There is NO data coming into DataAvailable at all (never fires).
FWIW: I get this same behaviour with VS2017 VB.NET and I thought I check this with something simpler than that.
Anyone got any ideas on what this could possibly be? This isn’t hard. Should be just falling off a log simple. Tera Term can do it not problem. Xojo should be able to do it too but it (and I) must be missing something in the connection.
The Example>Serial>Serial Port Bar Code Reader code works fine here using Windows 10, Xojo 2018r4 and the DataLogic PowerScan that I have on my desk. If its not working in Xojo or VS then it might be a set up issue that TeraTerm is taking care of.
If you add Break to the top of DataAvailable does it ever stop there?
If you grab the serial port with TeraTerm and try the Connect button in the xojo example, do you see a “A serial port error occurred” message followed by another error message?
Try it with coolterm, its made in xojo as i remember.
Use the same settings in your xojo program and it should work.
Coolterm can be found here
I’m getting no error on opening the port. And no data out or in.
I can open this thing using coolterm on a MAC no problem. Same Xojo/coolterm behaviour on the MAC as the PC. Odd
If you’re getting no error when opening the port while the port is open with another program then something is not working in Xojo to select and use the correct port.
no, the thing does get an error if there is something else with the port open.
Xojo project to test with is a slightly modified version of the example program for communications with a barcode reader. Modifications are to add a button that writes to the [open] serial port a line and removes the if statements from serial port data available so that it logs everything coming back
Behaviour is as follows
- bring up both coolterm and Xojo Project so both running and disconnected from any port
- connect to port with coolterm. Connects fine
- send/receive data from coolterm. Works fine.
- close port on coolterm
- open port on xojo project. No errors
- close port on Xojo project. No errors
- repeat 2-4 (no errors)
- Open port on Xojo Project. No errors
9 Send line out serial port . No errors on the Xojo end BUT nothing going out the serial port and nothing coming back either
- Close serial port. No errors
- Open port on coolterm. No errors
- attempt to send data with coolterm (nothing out, shows some sort of “working icon”). Nothing back in either.
- Disconnect Coolterm. No problems
The only way out of this is to drop the connection entirely and start over. So something at like an OS level is hanging up on this somehow.
BTW: Coolterm is a quite nice terminal emulator.
When you say “drop the connection entirely” could you explain how you’re doing that? Physically disconnecting the device?
here, inside ConnectButton.Action:
If SerialController.Open Then
Me.Caption = "Disconnect"
SerialPortsPopupMenu.Enabled = False
PortListUpdater.Mode = Timer.ModeOff
MsgBox("The selected serial port could not be opened.")
“disconnect” meaning pull the plug so the OS unloads it.
Putting this line in it does nothing to the behaviour. It’s almost like its holding off transmitting at an OS level somehow.
Also, I never get the data available event fired (breakpoint there never happens).
What serial uart chip is on the device? CP210x or FTDI?
So you can get coolterm into a state where it doesn’t work but only after you send across a string from your xojo program first?
Does this also happen using TeraTerm?
So if you open the port in Xojo, send a bit of data, close the port then run teraterm, will teraterm work ok or do you need to physically disconnect the device?
Below are three simple terminal programs written in Xojo that you can try to see if your issue persists.
Program 1 Simple Terminal using DataAvailble Event
Program 2 Simple Terminal using Timer to poll port and capture data via DataAvailble Event
Program 3 Simple Terminal using Timer to poll port and read data via Serial.ReadAll
They were previously shared in this thread to troubleshoot serial issues. If your device works with Coolterm it should work with one (or all) of these. I think you may have an issue setting up the port.
serial port in use is NXP K22FN512 version of it using CDC drivers.
The serial port hangs up once I attempt to send something with XoJo (both coolterm and teraterm) which is maybe indicative of CTS/DTR type problem perhaps. The only way out of it is to physically reset the connection by pulling the plug and letting it re-enumerate.
after some experimentation this morning, I think I have it… DTR isn’t being set on connect (even if you turn enable that in the serial port inspector and this device wants it apparently. Setting that allows sending data and getting stuff back…
you could set that just before opening the port you have to fiddle with RTS/CTS/DTR or look it up in the chips datasheet.