stdio.h

More
20 May 2011 18:14 #9951 by meisu
stdio.h was created by meisu
I'm trying to read a file with data in it and put that data on a pin. I'm trying to use functions in the stdio.h library but the comp compiler doesn't include stdio.h and all of it's dependencies. Does anyone have any suggestions?

Thanks,
Peter

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

More
20 May 2011 23:41 #9959 by BigJohnT
Replied by BigJohnT on topic Re:stdio.h
Comp is a bit limited and designed for simple components. If you needs are special write it in C then compile.

John

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

More
23 May 2011 15:22 #9995 by meisu
Replied by meisu on topic Re:stdio.h
That's what I was doing, but I was trying to compile with the comp compiler. Should I use a different compiler?

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

More
23 May 2011 16:20 #9996 by psha
Replied by psha on topic Re:stdio.h
If you want realtime component you are not allowed to use stdio.h and everything else from libc.
Realtime components are executed in kernel space and thus it's not possible to link with arbitrary userspace libraries

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

More
23 May 2011 16:21 #9997 by andypugh
Replied by andypugh on topic Re:stdio.h
You can use a #include statement in the code after the ;; and many of the sample files in the docs do this:
linuxcnc.org/docs/html/hal_comp.html

Alternatively, if you need the #include statement to be earlier in the generated C-code, you can use the undocumented "include" keyword before the ;; in the .comp file.
component random_example "this component includes libraries"
pin bit in random_pin

include <stdio.h>

;;

#include <stdio.h>

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

More
23 May 2011 16:36 #9998 by andypugh
Replied by andypugh on topic Re:stdio.h
psha wrote:

If you want realtime component you are not allowed to use stdio.h and everything else from libc.
Realtime components are executed in kernel space and thus it's not possible to link with arbitrary userspace libraries


Good point. He probably needs to use rtapi_print
www.linuxcnc.org/docview/html/man/man3/rtapi_print.3rtapi.html

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

More
24 May 2011 08:37 - 24 May 2011 08:38 #10021 by ArcEye
Replied by ArcEye on topic Re:stdio.h
Hi

When writing a realtime module it is however surprising what is still available, sometimes in different headers than you might be used to.

I am writing a serial comms module at present and I trawled through to see if it was possible to write as a real time module.
It of course isn't, unless you wanted to re-write half of the C library and address raw devices, it is after all a kernel module.

It was interesting to find the functionality that was available however. Comp searches the /usr/src/linux-headers-2.6.32-122-rtai/include directory on my setup by default, so putting #include<linux/termios.h> for example will work.

It is worth considering writing a user-space module, unless your application is extremely time critical.

I was surprised at how often polling occurred and found this route more than sufficient to check for the next byte on a serial stream and respond to it.
With of course the big advantage of having stdlib.h stdio.h string.h etc etc. available to address everything at an abstracted higher level.

good luck
Last edit: 24 May 2011 08:38 by ArcEye.

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

Time to create page: 0.069 seconds
Powered by Kunena Forum