trouble accessing hal variables from custom M code

More
4 years 9 months ago #233141 by gerrg
for sure, here they both are. I had to zip it up, because it didn't like the M100 file not having an extension
Attachments:
More
4 years 9 months ago #233161 by andypugh
I don't see anything obviously wrong with the files.

1) The M-code really should run as an executable, but Linux requires a dummy path in front of random executable files.
So try uncommenting the echo telltale, moving to the mcode directory and issuing the command ./M100. That should work, without the bash command.

2) It is just about possible that /bin/bash isn't the path to bash on your machine. You could try #!/bin/sh instead.

First get the script working as a standalone executable (./M100 or from hour home folder ./linuxcnc/configs/Gerrgs_PNC/m_codes/M100
More
4 years 9 months ago #233184 by gerrg
okay, so everything seems to work now except for the user_M_path directory. Here's what i've done to get it to work.

when using the ./M100 from the directory, it was giving me a "/bin/bash^M: bad interpreter" which looked like there was a hidden character in there. I tried editing the file from nano (just deleting that line and re-writing it) but that didn't seem to work. So then I just deleted the whole file and re-wrote it in vi  (just "sudo vi M100"), and that seemed to make it work correctly from the terminal without adding bash infront of it.

Tested it out first with the callout "USER_M_PATH = /home/gerrg/linuxcnc/configs/Gerrgs_PNC/m_codes/" in my INI file, but no sending the MDI command still didn't change anything. After commenting that line out so it points to the nc_files folder, I restarted everything (and moved new M100 file to the nc_files folder), and it worked! I might fiddle with stuff a bit more to try to get the M codes into a folder (either in the config file or the NC_files folder), but for now it works, so that's the biggest problem solved.

I typicaly use notepad++ on my windows PC to edit any text files on my linuxCNC PC, so i'm guessing that's where the extra hidden characters popped up. I'll try to find an easier work around than using vi since it's a bit funky to me, but I can at least make it work, so that's good. If anyone has any other advice, I'd be glad to hear it, but thanks everyone for helping me get this fixed!
 
More
4 years 9 months ago #233194 by andypugh
I use Notepad++ a fair bit, you can set it to show all characters to be sure what is going in, and choose the line end style by double clicking where it (should) say Unix (LF) on the bottom right of the window.
Maybe the file was being saved in a bizarre encoding?
More
4 years 9 months ago #233205 by gerrg
Ahh, I think that'll do it, Thanks! I'll make a new M101 file or something and test it out.
More
4 years 9 months ago #233220 by rodw
there is also a command line utility called dos2unix that cleans up the file.
As Andy says, its important notepad++ is in the right mode shown on the status line.
Time to create page: 0.505 seconds
Powered by Kunena Forum