A bit more information on debugging the Python.  When run from the command line 
with a Python error you get the same information that happens if you run from 
the desktop.  The added advantage is that when it's running correctly you can 
still get log messages.   I've added  a print statement and serial write 
statement in the 

except KeyboardInterrupt:
    print("CANSUB: Closing CANUSB")
    ser.write('C\r'.encode('utf-8'))
    raise SystemExit

And that print now shows up in the terminal screen when LCNC is closed.  It 
does not show up in the two log files:
/home/pi/linuxcnc_print.txt
/home/pi/linuxcnc_debug.txt

My python program also sends out, once per minute,  an 'F' command to the 
CANUSB to request/reset error flags for detecting things like bus and buffer 
errors.  

h.newpin("CANUSB_Flags", hal.HAL_U32, hal.HAL_OUT) 

I read this in LinuxCNC as h.CANUSB_Flags.  If there is an error it remains for 
1 minute until the next 'F' command.  Don't know how to throw up a dialog box 
if the value is non-zero but probably should.  Maybe also want this to be an IO 
pin to send back a request to resend the 'F' to see if the problem is sticky or 
transient.

John

> -----Original Message-----
> From: John Dammeyer [mailto:jo...@autoartisans.com]
> Sent: September-14-21 1:01 PM
> To: 'Enhanced Machine Controller (EMC)'
> Subject: Re: [Emc-users] Debugging Python under LinuxCNC
> 
> > From: andy pugh [mailto:bodge...@gmail.com]
> >
> > On Mon, 13 Sept 2021 at 21:49, John Dammeyer <jo...@autoartisans.com> wrote:
> >
> > > If I add print() statements where would they show up?  Or would they at 
> > > all?
> >
> > In the terminal, if you start  LinuxCNC from the command line.
> > Otherwise I fear that they might simply get lost.
> >
> Thanks Andy,
> From the desktop I can enable the start from terminal and leave it active but 
> it's really hard to cut and paste information from that.
> Starting the same command line as the desktop icon but from a terminal gives 
> he ability to copy to the clipboard.
> I then edited the serial-relay.py to remove a comment from in front of a 
> print statement, re-ran it, and indeed there are the CAN
> messages.  I've attached a bit of that if anyone is interested they can see 
> how it's part of the output that occurs when LCNC doesn't
> start up correctly.
> 
> Is by chance this information already being logged to some other file 
> somewhere when not started as a terminal session?
> 
> John
> 
> 




_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to