On 03/17/2017 08:18 PM, Trần Ngọc Quân wrote: > Hi, > I try to read from system fs, but it don't work? > Please see the attachment and help me fix it. > Thanks in advance!
Realtime comps can't read from sysfs (or any files), but userspace comps (aka non-realtime comps) can. There are a couple of bugs in your comp, and one bug in halcompile that prevents your comp from working. The bugs in your comp are: * You need to #include unistd.h for read() and usleep() * You need to rewind the file descriptor using lseek() before each read * And you should check the open() and read() for errors. The bug in halcompile affects singleton userspace components, add this line to the top of your user_mainloop() to work around it: struct __comp_state *__comp_inst = __comp_first_inst; I opened issue #245 to track the halcompile bug: https://github.com/LinuxCNC/linuxcnc/issues/245 -- Sebastian Kuzminsky ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Emc-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-users
