02-19-2024 02:46 AM
Hello,
I want to pilot a relay ch380 with CVI but to open the relay, I need to send this : \xA0\x01\x00\xA2 .
But CVI interpret the \x00 like a end of string of characters.
I try to use memcpy beacause i see someone with the same problem but that dont work.
Can someone help me please
Lucas
(sorry for my bad english)
02-19-2024 06:00 AM
Yes, 0x00 character marks the end of a string so every function that handles strings will fail.
You must double check your code to exclude all of them: using memcpy can be of help, but you must also avoid using strlen () to determine the number of bytes to send.
Just as an example, supposing to use serial communications (but this applies also to other channels):
char string[8];
string[0] = 0xA0;
string[1] = 0x01;
string[2] = 0x00;
string[3] = 0xA2;
ComWrt (port, string, strlen (string)); // This will fail
ComWrt (port, string, 4); // This will succeed