Stutchbury / Manualmatic-Pendant

A 'manualmatic' MPG/Pendant for LinuxCNC
29 stars 4 forks source link

linuxcnc not starting #3

Closed TadyTheFish closed 1 year ago

TadyTheFish commented 1 year ago

I'm having a problem with you project. I cant start Linuxcnc I followed your instructions

TadyTheFish commented 1 year ago

I changed the shebang in manualmatic from #!/usr/bin/python to #!/usr/bin/python3 and it loads up but threre are other problems

Traceback (most recent call last):
  File "/home/linuxcnc/Desktop/tady/./manualmatic", line 28, in <module>
    mm.connect(PORT)
  File "/home/linuxcnc/Desktop/tady/Manualmatic.py", line 714, in connect
    self.sendIniValues()
  File "/home/linuxcnc/Desktop/tady/Manualmatic.py", line 196, in sendIniValues
    self.writeToSerial(self.CMD_INI_VALUE+self.INI_AXES, format(self.ls.axes))
AttributeError: 'linuxcnc.stat' object has no attribute 'axes'. Did you mean: 'axis'?

If i change to axis there is a tuple error

Stutchbury commented 1 year ago

Wow, you're a long way ahead! The Manualmatic uses the Python interface as at 2.8.x - it looks like there have been changes made for 2.10.

The 'stat' is the status object documented here for 2.8: http://linuxcnc.org/docs/html/config/python-interface.html#_reading_linuxcnc_status

Here for 2.9: https://github.com/LinuxCNC/linuxcnc/blob/2.9/docs/src/config/python-interface.adoc

And here for master: https://github.com/LinuxCNC/linuxcnc/blob/master/docs/src/config/python-interface.adoc

I can't see a 2.10 specific branch - if you can point me towards it, that would be good.

'axes' is the number of axes (axis's?) configured so I'm not sure why that would be renamed/removed.

TadyTheFish commented 1 year ago

here is an explanation https://forum.linuxcnc.org/29-forum-announcements/47328-master-is-now-linuxcnc-v2-10 it's actually 2.9 . So it seems I'm a little to far ahead :) Thanks for the links I know a little about linuxcnc and I modified a mesa ethernet driver for a STM32 board, but I don't know alot more of the internals. So I will dig a little trough the docs and source to modify your code :)

TadyTheFish commented 1 year ago

well Try to modify it :D

Stutchbury commented 1 year ago

The code shouldn't be too hard (after all, I wrote it! :) ) - please leave notes here - I'll leave this ticket open.

TadyTheFish commented 1 year ago

Don't sell your self short. Your coding skills ar wayyy batter than mine but I will try my best 😁

TadyTheFish commented 1 year ago

Well there seems to be a problem with Linuxcnc 2.9 (2.10). I added print(dir(linuxcnc.stat)) to manualmatic (component file) and it printed out: ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'acceleration', 'active_queue', 'actual_position', 'adaptive_feed_enabled', 'ain', 'angular_units', 'aout', 'axis', 'axis_mask', 'block_delete', 'call_level', 'command', 'current_line', 'current_vel', 'cycle_time', 'debug', 'delay_left', 'din', 'distance_to_go', 'dout', 'dtg', 'echo_serial_number', 'enabled', 'estop', 'exec_state', 'feed_hold_enabled', 'feed_override_enabled', 'feedrate', 'file', 'flood', 'g5x_index', 'g5x_offset', 'g92_offset', 'gcodes', 'homed', 'ini_filename', 'inpos', 'input_timeout', 'interp_state', 'interpreter_errcode', 'joint', 'joint_actual_position', 'joint_position', 'joints', 'kinematics_type', 'limit', 'linear_units', 'lube', 'lube_level', 'max_acceleration', 'max_velocity', 'mcodes', 'misc_error', 'mist', 'motion_id', 'motion_line', 'motion_mode', 'motion_type', 'num_extrajoints', 'optional_stop', 'paused', 'pocket_prepped', 'poll', 'position', 'probe_tripped', 'probe_val', 'probed_position', 'probing', 'program_units', 'queue', 'queue_full', 'queued_mdi_commands', 'rapidrate', 'read_line', 'rotation_xy', 'settings', 'spindle', 'spindles', 'state', 'task_mode', 'task_paused', 'task_state', 'tool_from_pocket', 'tool_in_spindle', 'tool_offset', 'tool_table', 'velocity'] No Axes .. to me it seems to be a Linuxcnc bug ... We should report this to the official forum Also if I comment out the self.ls.axes line it then complains that the poll() attribute needs an argument. This also seems to be a problem, the Linuxcnc docs say nothing about passing an argument to the pool() function

Stutchbury commented 1 year ago

Well that's a bit worrying. If you could raise a ticket on the LinuxCNC repository that would be very much appreciated (I don't currently have a 2.9 or 2.10 install). Perhaps also one for the poll() argument too - at least a documentation update. I have tried (in the past too) to find out where the Python Interface is defined in src so I can understand it better but always end up down the wrong rabbit hole...

TadyTheFish commented 1 year ago

I was also wondering where could I find this in the source code🤔. How do you open a ticket. I never did this?

Stutchbury commented 1 year ago

Let me know if you find it! This is where you raise issues for LinuxCNC: https://github.com/LinuxCNC/linuxcnc/issues When you click 'New issue' it provides a 'template' to ease you through the submission - the same process as this one but a much bigger, more talented & organised development community!

TadyTheFish commented 1 year ago

I did some digging and I THINK these python things are here: /home/linuxcnc/linuxcnc-dev/src/emc/usr_intf/axis/extensions/emcmodule.cc

andypugh commented 1 year ago

The issue is the use of stat.axes to return the number of axes in use.

The code should now iterate through the axis mask instead. This is because previously you needed dummy axes for lathes or other configurations with a missing axis. So lathes (XZ) needed a dummy Y, and a 4 axis XYZC mill would need a dummy A and B.

See https://github.com/LinuxCNC/linuxcnc/commit/ffe664c0422887c899be5cd59de6b1cb1d1bbc4c

Stutchbury commented 1 year ago

Well done - looking at the history of that file, it would seem axis and axes were deprecated in 2015! I didn't see mention of that in the Python Interface...

https://github.com/LinuxCNC/linuxcnc/commit/ffe664c0422887c899be5cd59de6b1cb1d1bbc4c

Stutchbury commented 1 year ago

Thanks Andy - I think we posted at the same time! I guess I have some work to do for 2.9 compatibility...

TadyTheFish commented 1 year ago

I faked your python file and added 3 instead of self.ls.axes and it works, even with a Aliexpress LCD (when RESET pin is also connected). I moved the loadusr -W ./manualmatic gmoccapy.ini to the gmoccapy_postgui.hal (that was also my mistake). I also tested the axes_mask and it returns 7 on a XYZ machine. So the code needs some adjusting to take the mask value and turn it in to number of axes:) Also I couldnt see the PDF file (that you posted on the linuxcnc forum) here on your git repo

andypugh commented 1 year ago

I think this should be left open until there is a fix that works for all users, rather than one user putting in a workaround.

Stutchbury commented 1 year ago

I have re-opened - I probably need to rework the use/checking of valid axes. The code is currently focused on a very simple 3 axis mill - I just needed to start making chips!

TadyTheFish commented 1 year ago

I closed the issue thinking there is an answer to the problem.. Sorry

Stutchbury commented 1 year ago

No worries. I have added the (more-dev-than-user) User Guide here: https://github.com/Stutchbury/Manualmatic-Pendant/blob/main/docs/pendant_user_guide.pdf

Stutchbury commented 1 year ago

I have pushed a new version of Manualmatic.py ( https://github.com/Stutchbury/Manualmatic-Pendant/blob/main/Software/linuxcnc/python-component/Manualmatic.py ) that removes the use of the deprecated linuxcnc.stat.axes so should work for 2.8, 2.9 and 2.10.

This does raise questions on non-contiguous axes (eg XYZB rather than XYZA) but given that I've not written anything for rotational axes, that falls squarely in the todo/too hard pile.

If you could test on your 2.9 & 2.10 installs, that would be much appreciated.

TadyTheFish commented 1 year ago

I will do some tests tomorow. I use teensy 3.6 with an aliexpress LCD. I do have two other thing to advise.

  1. Change #!/usr/bin/python in manualmatic component file to #!/usr/bin/python3 Or make a note in the documentation (readme) for people to install $ sudo apt install python-is-python3
  2. Make a note in the documentation (readme) for people to install pySerial. It's the only dependency pip3 install pySerial or pip install pySerial

Way easier for people that struggle with programming stuff 😉

Stutchbury commented 1 year ago

Thanks. I've not tested with a Teensy 3.6 so I'll be interested to know if it works. I tried python3 on my 2.8 install last week and it couldn't find the hal component, so I probably need to do a bit more research. I've never had to install pySerial on 2.8 (I've just done a fresh install on a NUC without having to) but I'll make a note in the docs. Perhaps a difference between Python 2 and 3?

TadyTheFish commented 1 year ago

Some quick testing showed me that it does work with 3.6 and maybe even 3.5. Nothing to change just compile for 3.6. The lcd works and it connects to linuxcnc. My MPG didn't work. I selected the X axis and when i turned the MPG nothing happened 🤷‍♂️ i will test some more maybe there is a kink in my MPG. As for your python3 problem i had the reverse problem. With 2.9 (2.10) if I leave everything as is, linuxcnc does not find the manualmatic file, but if I change the shebang to python3 it works I think Linuxcnc 2.8 uses python2 and newer versions are ported to python3. Python2 support ended a few years ago so it makes sense to develop or port software to python3

TadyTheFish commented 1 year ago

Maybe it's best to leave the shebang and make a note "if you use linuxcnc 2.9 and newer install python-is-python3"

Stutchbury commented 1 year ago

I will definitely make notes in the docs. Can I suggest you use 2.8 to test your pendant - too many variables if you're also using a Teensy 3.6!

TadyTheFish commented 1 year ago

I need to reinstall the whole system for 2.8. I have a spare disk I can use. What do you mean by too many variables? how do you debug the component? HAL does not show any signals or pins?

Stutchbury commented 1 year ago

The 'too many variables' is that you're using a Teensy 3.6 and a a possibly dodgy MPG with LinuxCNC 2.9+ - I have tested against 2.8 so you can be sure that will work in order to test the Teensy 3.6 and your MPG. Once you're sure they're working as expected then move to testing 2.9+ with a known working pendant. Hal will not show any pins for the component because we are using the user space Python interface. The easiest way to debug the component is to run LinuxCNC from the command line - if you right click on the desktop icon for your config and choose the 'Properties' and then 'Desktop Entry' it will show the command you need to run. For my Pi the sim config is: /usr/bin/linuxcnc '/home/pi/linuxcnc/configs/sim.gmoccapy/gmoccapy.ini' - yours will be something similar. Any print() commands you put in the Python code will be echoed to the terminal.

TadyTheFish commented 1 year ago

I run my instance in a terminal (I use the RIP enviroment). Aaaa ok that is what I wanted to know if you debug with print() or is there a option to do it in HAL. Glad that is cleared up :) Ok I will install 2.8 on a disk and test with that

Stutchbury commented 1 year ago

I have now tested on 2.9 using the buildbot debs for Debian 12 (and even have dual boot Buster/2.8 & Bookworm/2.9 on my mill). The only issue is that vanilla 2.9 requires #!/usr/bin/python3 hash bang in the manualmatic component file rather than just #!/usr/bin/python. The latest code for Manualmatic is currently in the dev branch - will push when I'm happy it is all stable.

TadyTheFish commented 1 year ago

We slould probably close this issue. I have put on hold this project since I'm currently developing an EtherCAT to analog servo interface. But I will come back for this :)