halpin of type "char".

  • Grotius
  • Grotius's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
29 Jun 2021 11:33 #213226 by Grotius
halpin of type "char". was created by Grotius
Hi,

I need a halpin of type "char".  It must hold a char text like : "/opt/linuxcnc"
Then user could set the value by "setp charpin /opt/linuxcnc"

Is there such a option? Or must the hal source code by modified to accieve this?
 

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

  • BeagleBrainz
  • BeagleBrainz's Avatar
  • Visitor
  • Visitor
29 Jun 2021 12:03 - 29 Jun 2021 12:06 #213229 by BeagleBrainz
Replied by BeagleBrainz on topic halpin of type "char".
This is an example I've used, to specify an IP address as a string.

RTAPI_MP_STRING(ipaddress,"ESP IP Address");

option extra_setup yes; is required

Example code
EXTRA_SETUP(){

if (ipaddress == 0) {
rtapi_print_msg(RTAPI_MSG_ERR,"Message string for ESP32 IP Address missing\n");
return -EINVAL;
}
rtapi_print_msg(RTAPI_MSG_ERR,"Message string for ESP32 IP Address %s\n",ipaddress);
return(0);
}

Bit more info here:
linuxcnc.org/docs/2.8/html/man/man3/RTAP...Y_STRING.3rtapi.html

Thread where Andy answered my question forum.linuxcnc.org/24-hal-components/426...-when-loading#209746
Last edit: 29 Jun 2021 12:06 by BeagleBrainz.

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

  • Grotius
  • Grotius's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
29 Jun 2021 22:28 - 29 Jun 2021 22:28 #213281 by Grotius
Replied by Grotius on topic halpin of type "char".
Hi,

This is nice! It works. Thank you for this.
I attached a template implementation for passing a single string as argument.










 
Attachments:
Last edit: 29 Jun 2021 22:28 by Grotius.

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

  • Grotius
  • Grotius's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
02 Jul 2021 04:00 #213479 by Grotius
Replied by Grotius on topic halpin of type "char".
Hi,

I think i really need a halpin of type "char".
In a upcoming project a .ngc file has to be loaded from the component.
I need to be able to pass a "char array" to a component input pin.

Passing a string at the component init stage is ok, but not usable at runtime.

Do i need to add this "char" pin to the source code?

 

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

More
02 Jul 2021 12:51 #213491 by rodw
Replied by rodw on topic halpin of type "char".
Hal_port might do it for you. New in V 2.9 but badly documented.
The following user(s) said Thank You: Grotius

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

  • Grotius
  • Grotius's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
02 Jul 2021 13:47 #213495 by Grotius
Replied by Grotius on topic halpin of type "char".
Hi Rod,

Thank you for your advice !

I did some research in the mean time, before reading your post.
After editing a few source files it works!

I can now create char's for hal pin and hal parameters and use them with halcommmand.

Attachments:

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

  • Grotius
  • Grotius's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
03 Jul 2021 21:17 - 03 Jul 2021 21:22 #213590 by Grotius
Replied by Grotius on topic halpin of type "char".
Hi Rod,

You where right !.

I managed to get the port function working in a example component "port.so"

It sends a string (char array) from point a to point b trough hal.

This example uses one component.
Normally it would serve between at least 2 components.

It is indeed badly documented.
The buffer is allocated by a setsignal command, this is quite unusual.

For the rest it works out of the box ! Many thanks for your advice !


 

 
Attachments:
Last edit: 03 Jul 2021 21:22 by Grotius.

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

Time to create page: 0.191 seconds
Powered by Kunena Forum