Results 1 to 8 of 8

Thread: Moving stage using udp command in qt gui

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Jan 2016
    Posts
    6
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Moving stage using udp command in qt gui

    Quote Originally Posted by ChrisW67 View Post
    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:
    Qt Code:
    1. sendBytes[0] = 0;
    2. sendBytes[1] = 7;
    3. Byte[] SCLstring = Encoding.ASCII.GetBytes(“RV”); // for sendin RV command///
    4. // copy string to the byte array
    5. System.Array.Copy(SCLstring, 0, sendBytes, 2, SCLstring.Length);
    6. // insert terminator
    7. sendBytes[sendBytes.Length - 1] = 13; // CR
    8. // send it to the drive
    9. udpClient.Send(sendBytes, sendBytes.Length);
    To copy to clipboard, switch view to plain text mode 



    should i create array of specific length then?

    Quote Originally Posted by d_stranz View Post
    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
    Last edited by ankit.1g@gmail.com; 1st February 2016 at 14:39.

Similar Threads

  1. Replies: 3
    Last Post: 2nd December 2012, 14:10
  2. Stage active event from QML file
    By AbinaThomas in forum Qt Programming
    Replies: 1
    Last Post: 8th September 2012, 05:05
  3. How to make fewer errors at the stage of code writing. Part N3. QT.
    By Andrey_Karpov in forum General Discussion
    Replies: 0
    Last Post: 13th July 2011, 07:39
  4. Replies: 1
    Last Post: 12th April 2010, 12:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.