How do I connect via COM port?
-
wrote on 5 Aug 2016, 22:11 last edited by hskoglund 8 May 2016, 22:16
Hi, I've also struggled with COM ports (connecting a PC to cigarette vending machines :-) and to see what's going on in the COM port, I use PortMon
Run it before starting your Qt app, and it will show everything that happens with your COM port.
(Note: Last time I tested I couldn't get PortMon to run in Windows 10, but Windows 7 works fine.)Edit: forgot to answer you question: yes, it's true that only one program at the time can use a specific COM port, so you have to check that open() worked. (PortMon uses some low-level tricks to open it anyway, but that's another story.)
-
wrote on 5 Aug 2016, 23:51 last edited by
I'm taking a look at PortMon now! Thanks.
Although, I do wonder if it will work - since it's a driver for an application and not an application itself, I actually can't even really test my code except via the third party app itself. And at that point, the program is already in DLL form. That said, if PortMon is supposed to show port requests - and assuming there are no setup steps I'm missing - it doesn't appear to be really doing anything. I didn't see anything pop up when trying to execute the connection for my program.Any thoughts?
-
wrote on 6 Aug 2016, 00:07 last edited by hskoglund 8 Jun 2016, 00:13
Hi, about PortMon, it doesn't show any popups, to see what's happening, you need to have PortMon's window visible, it will show the events in it, for example if a program opens that COM port, or changes the speed etc.
Edit: also in the Capture menu in PortMon, check in the Ports submenu that your COM port is captured ok, that helps :-)
-
wrote on 6 Aug 2016, 00:12 last edited by
Hmm.. right now nothing is popping up in the window (that's what I meant by pop up, my mistake) and the window says Portmon - not connected. Is there some step I'm missing?
-
wrote on 6 Aug 2016, 00:15 last edited by
If it's not connected, perhaps you didn't start PortMon before starting your driver and app; it needs to be launched before your stuff. Also check that Capture submenu (as I said in my prev. post).
-
wrote on 6 Aug 2016, 00:31 last edited by
Ah, didn't refresh my site to see that edit - well, the Ports submenu is grayed out and I tried closing and reopening the apps in the proper order and still nothing...
-
wrote on 6 Aug 2016, 00:40 last edited by
Hnmm, perhaps this StackOverflow post can help (look at the answer at the bottom)
-
wrote on 6 Aug 2016, 01:03 last edited by
That method's throwing a file not found error... haha I can't even work the thing that's supposed to work the thing I can't work
-
wrote on 6 Aug 2016, 01:48 last edited by
It's called yak shaving :-)
COM ports are indeed finicky to debug. In the old days I used a hardware dongle with LEDs and RS232 male/female connectors as a "hardware" debugger, when the LEDS flashed you'd know something was afoot.
Another alternative is to use ol' HyperTerminal if you have Windows XP somewhere it's included.
-
wrote on 6 Aug 2016, 02:13 last edited by
Yeah I tried opening Portmon and then just moving the program into my arduino to see if the activity popped up in the feed but nothing happened, though the program loaded successfully (although that was never a problem). I'm also not using XP, unfortunately. Seems that port checking may not be the way to go for this troubleshooting?
-
wrote on 6 Aug 2016, 02:42 last edited by
Yeah sorry PortMon may well have past its prime. You could try connecting the cable to another PC instead of the Arduino board, and on that other PC run Qt's chat demo program or something similar.
Also another trick I remember, take a paperclip and connect/shortcircuit pins 2 and 3 with each other, easiest on the male RS232-connector. When you connect the Tx and Rx pins that way, it means everything you transmit comes back directly (echo). Sometimes that can be a helpful diagnostic, just to see if anything arrives...
19/20