Halcompile: stdio.h no such file or directory

More
20 Dec 2017 17:17 #103392 by AndrewHsasku
I would create Hal driver for serial port communication. I would use open function that is in stdio.h.
Compiling driver with #include <stdio.h> using
halcompile --install driver.c
prints:
make KBUILD_EXTRA_SYMBOLS=/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc/Module.symvers -C /usr/src/linux-headers-3.4-9-rtai-686-pae SUBDIRS=`pwd` CC=gcc V=0 modules
make[1]: Entering directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
  CC [M]  /tmp/tmpqrHbhd/driver.o
/tmp/tmpqrHbhd/driver.c:13:19: fatal error: stdio.h: No such file or directory
compilation terminated.
make[4]: *** [/tmp/tmpqrHbhd/driver.o] Error 1
make[3]: *** [_module_/tmp/tmpqrHbhd] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
make: *** [modules] Error 2

What to do?

Please Log in or Create an account to join the conversation.

More
20 Dec 2017 17:32 #103393 by AndrewHsasku
Using
sudo halcompile --install --userspace driver.c
Results in:
gcc -Os -g -I. -I/usr/realtime-3.4-9-rtai-686-pae/include -I. -I/usr/realtime-3.4-9-rtai-686-pae/include -I/usr/include/i386-linux-gnu -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fno-math-errno -funsafe-math-optimizations -fno-rounding-math -fno-signaling-nans -fcx-limited-range -mhard-float -DRTAI=3 -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/usr/include/linuxcnc -Wframe-larger-than=2560 -URTAPI -U__MODULE__ -DULAPI -Os  -o driver /tmp/tmpNAGuWQ/driver.c -Wl,-rpath,/lib -L/lib -llinuxcnchal 
/usr/lib/gcc/i486-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
/tmp/ccwZbC2U.o: In function `rtapi_app_main':
/tmp/tmpNAGuWQ/driver.c:68: undefined reference to `hal_export_funct'
/tmp/tmpNAGuWQ/driver.c:75: undefined reference to `hal_export_funct'
collect2: error: ld returned 1 exit status
make: *** [driver] Error 1
undefined reference to `hal_export_funct' is a problem

Please Log in or Create an account to join the conversation.

More
24 Dec 2017 01:00 #103504 by andypugh
Rather than using #include in the C code you could try using the "include" command above the ;; marker in the comp.

(This is undocumented, but you can find it in the halcompile source:
github.com/LinuxCNC/linuxcnc/blob/master...ils/halcompile.g#L46 )

If you use --preprocess you will see the difference between the two: A #include in the C-code ends up further down the file than the declarations that need it.

It _still_ might not work, but it is worth a try.

Please Log in or Create an account to join the conversation.

More
24 Dec 2017 01:03 #103505 by AndrewHsasku
I ve read about it before posting this topic - did not work.
Installing debian on own with Preempt-RT kernel was a solution.

Please Log in or Create an account to join the conversation.

More
24 Dec 2017 10:44 #103531 by andypugh
Thinking further: You probably don't want stdio.h anyway.

For a realtime module you want the guaranteed-threadsafe things from rtapi.
linuxcnc.org/docs/2.7/html/man/man3/intro.3rtapi.html

The list is at the bottom of linuxcnc.org/docs/2.7/html/

You probably wanted linuxcnc.org/docs/2.7/html/man/man3/rtapi_print.3rtapi.html

Please Log in or Create an account to join the conversation.

More
24 Dec 2017 11:31 #103538 by AndrewHsasku
I do not care about real-timing. Latencies like 20ms are absolutely ok.
I would use usb-uart device and communicate with it via linuxcnc.

Please Log in or Create an account to join the conversation.

More
24 Dec 2017 13:36 #103545 by andypugh

I do not care about real-timing. Latencies like 20ms are absolutely ok.


Not if it is a realtime component. The realtime components run one at a time in sequence. If your component blocks for 20mS then everything else stops too.

If it is a userspace component, (option userspace) then this is not a problem.

Please Log in or Create an account to join the conversation.

More
24 Dec 2017 13:50 #103547 by AndrewHsasku
How to create such, non python, component? Any example?

Please Log in or Create an account to join the conversation.

More
24 Dec 2017 15:37 #103554 by andypugh
Here is an example
github.com/LinuxCNC/linuxcnc/blob/af15a4...cs/src/hal/rand.comp

You need the user_mainloop and you can cycle though all the instances with the FOR_ALL_INSTS macro.

Please Log in or Create an account to join the conversation.

Time to create page: 0.188 seconds
Powered by Kunena Forum