Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom messages from CodeSys structs: Error parsing Array of Strings #11

Open
2b-t opened this issue Mar 18, 2021 · 2 comments
Open

Custom messages from CodeSys structs: Error parsing Array of Strings #11

2b-t opened this issue Mar 18, 2021 · 2 comments

Comments

@2b-t
Copy link

2b-t commented Mar 18, 2021

Hey again,
I have encountered another error when creating custom messages from CodeSys structs similar to the previously reported issue #10. When using the data type ARRAY[1..n] OF STRING as a message type in a custom struct such as

TYPE TestStruct :
STRUCT
	var_string: ARRAY[1..32] OF STRING;
END_STRUCT
END_TYPE

with a program in structured text

PROGRAM ROS_PRG
VAR_INPUT
	struct_to_codesys: TestStruct;
END_VAR
VAR
	robin: Robin;
END_VAR

that contains a subscriber (the corresponding publisher seems to work)

robin();
robin.read('struct_to_codesys', struct_to_codesys);

this results in the error message

* * * * * * * * * * * * *
* * * Robin Updater * * *
* * * * * * * * * * * * *

Creating SSH key ...

Adding SSH key to agent ...
Identity added: C:\Users\lab\.ssh\robin_key (C:\Users\lab\.ssh\robin_key)

Adding SSH key to target ... Password will be required
[email protected]'s password:
[sudo] password for user: Accessing target through ssh... Ensure ssh service is ON. 
Connecting... 
sa-sha2-512)
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)

Generating source code...

Generating new ros package robin_bridge_generated...

Recompiling...
NOTICE: Could not determine the width of the terminal. A default width of 80 will be used. This warning will only be printed once.
_______________________________________________________________________________
Errors << robin_bridge_generated:make /home/user/catkin_ws/logs/robin_bridge_generated/build.make.118.log
/home/user/catkin_ws/src/robin_bridge_generated/src/robin_bridge_generated/robin_inst.cpp: In member function ?void RobinSubscriber<T1, T2>::write(const T2*) [with T1 = TestStruct; T2 = robin_bridge_generated::TestStruct_<std::allocator<void> >]?:
/home/user/catkin_ws/src/robin_bridge_generated/src/robin_bridge_generated/robin_inst.cpp:14:43: error: invalid conversion from ?char? to ?char*? [-fpermissive]
     std::snprintf((*shm_ptr_).var_string[i_0], sizeof((*shm_ptr_).var_string[i_0]), "%s", (*msg_ptr).var_string[i_0].c_str());
                   ~~~~~~~~~~~~~~~~~~~~~~~~^
In file included from /usr/include/features.h:424:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/cstdio:41,
                 from /home/user/catkin_ws/src/robin_bridge_generated/src/robin_bridge_generated/robin_inst.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:61:1: note:   initializing argument 1 of ?int snprintf(char*, size_t, const char*, ...)?
 __NTH (snprintf (char *__restrict __s, size_t __n,
 ^
make[2]: *** [CMakeFiles/robin_inst_generated.dir/src/robin_bridge_generated/robin_inst.cpp.o] Error 1
make[1]: *** [CMakeFiles/robin_inst_generated.dir/all] Error 2
make: *** [all] Error 2
cd /home/user/catkin_ws/build/robin_bridge_generated; catkin build --get-env robin_bridge_generated | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -
WARNING: Could not encode unicode characters. Please set the PYTHONIOENCODING environment variable to see complete output. (i.e. PYTHONIOENCODING=UTF-8)
...............................................................................
Failed << robin_bridge_generated:make            [ Exited with code 2 ]
Traceback (most recent call last):
  File "./updater.py", line 401, in <module>
    Updater().update(catkin_ws=catkin_ws)
  File "./updater.py", line 79, in update
    self._recompile_robin(catkin_ws)
  File "./updater.py", line 296, in _recompile_robin
    raise RuntimeError('Failed to recompile robin_bridge_generated package.')
RuntimeError: Failed to recompile robin_bridge_generated package.

when executing the start_update.py script.


The reason for this seems to be that the script generates a message of the form

struct TestStruct
{
  char var_string[32];
};

in robin_generated/include/robin_bridge_generated/structs.h instead of

struct TestStruct
{
  char var_string[32][81];
};

I still have to look into more detail into the source code of updater.py and srcgen.py to propose a potential fix on a code level for it.

@2b-t 2b-t changed the title Custom messages from CodeSys structs: Error parsing String Custom messages from CodeSys structs: Error parsing Arrays of String Mar 18, 2021
@2b-t 2b-t changed the title Custom messages from CodeSys structs: Error parsing Arrays of String Custom messages from CodeSys structs: Error parsing Array of Strings Mar 18, 2021
@elia-sysdesign
Copy link

Hello.

I am having the same issue as @2b-t explains.
Do you have any suggestions how to tackle this problem?

Thank you.

@2b-t
Copy link
Author

2b-t commented May 8, 2023

Hi @elia-sysdesign
I changed it manually similar to what is described above, adding the [81]. I did not investigate further back then as for me it was a one time thing and they do not seem to merge any pull requests over here anymore.

P.S. Salutami Marco e Nicola.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants