Universal Robots Forum

How to access ascii values of a string variable?

Hi

Is there any way to convert a string variable to ascii values of each character?
I have to make XOR operation between each byte but it can’t be done without a conversion.
Or can I access values directly some way?

Hi @ville.hakala are you reading the string from a socket? If so the socket_read_byte_list() command in the urscript manual may be helpful.

Unfortunately no. I have to count XOR checksum and add it as last byte before sending it to socket.
At the moment I have external PC that makes this but I want to remove that redundant part.

You could use str_len() to find the length of the string and then str_at() to get each corresponding character based on the length found.

I think the easiest way to do this would be to set up a python daemon running on the command line on the controller to do the checksum and pass the results back to the robot program via xmlrpc:

https://www.universal-robots.com/articles/ur/interface-communication/xml-rpc-communication/