I'll answer part of my own question but it doesn't answer how to debug Python programs launched by LCNC.
First of all it's now working! These two lines # Copies of CAN dataRelayImage = 0 # No relays set yet. Mist_PWM = 0 # Mister pump motor speed 0 Fan_PWM = 0 # Cooling fan off. Should be: # Copies of CAN data RelayImage = 0 # No relays set yet. Mist_PWM = 0 # Mister pump motor speed 0 Fan_PWM = 0 # Cooling fan off. Somehow in editing the new line between the commented line and the RelayImage was deleted. No Error from the Python program to LCNC. Other than that it did nothing. Therefore Send_PDO_2(RelayImage) # Update device relays with default values. The above line failed because RelayImage had not yet been defined. So the question still stands. How to debug a Python program that has the statement import hal If I run ./serial-relays.py I get an error: HAL: ERROR: duplicate component name 'serial-relays' Traceback (most recent call last): File "./serial-relays.py", line 49, in <module> h = hal.component("serial-relays") hal.error Invalid argument Oh and what I did to get there was to replace the CANUSB with a Serial USB dongle and a null modem cable to connect to the COM1: of my PC. Then see what it was sending as text commands using the ser.write() function and where it hung. Thanks John > -----Original Message----- > From: John Dammeyer [mailto:jo...@autoartisans.com] > Sent: September-13-21 12:46 PM > To: Enhanced Machine Controller (EMC) > Subject: [Emc-users] Debugging Python under LinuxCNC > > The Python program I wrote includes hal. I'm using a Pi4 with LinuxCNC to > test all this. Thonny on the Pi4 will run a similar pySerial > project that doesn't include hal and spits out CAN messages through the > CANUSB so my hardware works. > > The original 'simple' version of serial_relays.py still works. > > However, the latest upgraded serial_relays.py program does not work properly. > I've been commenting out all sorts of stuff but still > no luck. > > How does one get diagnostics from a python program loaded in the hal file as > loadusr -Wn serial-relays ./serial-relays.py > > If I add print() statements where would they show up? Or would they at all? > > Suggestions? > > Thanks > John > > > "ELS! Nothing else works as well for your Lathe" > Automation Artisans Inc. > www dot autoartisans dot com > > > _______________________________________________ > Emc-users mailing list > Emc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/emc-users _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users