Originally Posted by
ChrisW67
It moved != it is working correctly... Even the first time
If the two bytes 0x00, 0x07 represent the length of the following command string then:
- Should the length include or exclude the trailing CR? Currently it would exclude the CR, which might leave the controller with a spurious byte in a buffer when it receives the next command datagram.
- Should the length value include the two bytes of the length indicator itself? Different spurious bytes in the buffer.
- Is the byte order correct? 0x00, 0x07 could mean 7 or 1792 decimal. Might still be waiting for more bytes to arrive.
the command is as:
Header = 07 (two bytes)
FL1000
<cr> (ASCII carriage return) = 13.
They only have C# example in the manual which forms the send bytes as:
sendBytes[0] = 0;
sendBytes[1] = 7;
Byte[] SCLstring = Encoding.ASCII.GetBytes(“RVâ€); // for sendin RV command///
// copy string to the byte array
System.Array.Copy(SCLstring, 0, sendBytes, 2, SCLstring.Length);
// insert terminator
sendBytes[sendBytes.Length - 1] = 13; // CR
// send it to the drive
udpClient.Send(sendBytes, sendBytes.Length);
sendBytes[0] = 0;
sendBytes[1] = 7;
Byte[] SCLstring = Encoding.ASCII.GetBytes(“RVâ€); // for sendin RV command///
// copy string to the byte array
System.Array.Copy(SCLstring, 0, sendBytes, 2, SCLstring.Length);
// insert terminator
sendBytes[sendBytes.Length - 1] = 13; // CR
// send it to the drive
udpClient.Send(sendBytes, sendBytes.Length);
To copy to clipboard, switch view to plain text mode
should i create array of specific length then?
Originally Posted by
d_stranz
Did you read the documentation (and example) for using
QUdpSocket? You are creating a new UDP socket on the stack every time you execute the button click slot. The firswt time around, this works, but maybe the second time around the old socket is still connected (even though UDP is supposed to be connectionless). Try creating a single QUdpSocket instance as a member of your MainWindow class instead.
How can I do that...? creating in main window? can you please give me an example.
thank you
Bookmarks