Transmitting a byte command via UDP

I hope you'll forgive the newbie question, but my education is in aerospace engineering and not computer science...
I have a verified specification document which tells me that in order to command a data source to begin transmitting data, I need to send it the following command via UDP:
1 byte        1 byte               2 bytes                              n bytes
COMMAND
01
00
Command Code =
8016
Data  
Where the data field is ignored for this command.
My best understanding of this situation would be to use the Byte Array to String function on an array of U8s which looks like this:
where the network order is big endian.  However, I have some functioning, inherited code which interfaces with the same data source and issues a start data command using an array which looks like this:
In classic style, the author of this code has retired and I'm the only other LabVIEW programmer.  I'm not savvy enough to tell whether this array accomplishes the same task and it's my limited understanding of bytes which is causing the confustion or if this command is combined with another command or what.
Any insight, leading questions, or valuable commentary is appreciated.
Solved!
Go to Solution.

I think I'm starting to understand how bits, bytes, and such behave with LabVIEW.  Kind of confusing without a solid background in computing...
According to the documentation-when using the startup command--there is no data payload required; it is ignored by the data source.  My only guess for those elements remaining after the 4th element are that they are simply placeholders so that the data source know this is a completed command or that the original programmer copied the array from one of the other commands (which required the data payload) and those are just residual values he knew were ignored and never bothered to delete.  It would be in keeping with the just-get-it-done approach this programmer favored.
Thanks for the assistance.  I think I can interpret the other commands for this data source now.
Cheers.

Similar Messages

  • How does one send a file via UDP?

    I need to send a binary file via UDP. The file has 99 32-bit binary words of data. How do I input the data to the UDP write command? I don't want to send the data sequentially..I would like to send all 99 words in a single UDP transmission. TIA.
    -jlivermore

    Something to be careful of is that while UDP is fast, it is not secure. You can lose packets and there is no way for the sender or receiver to know it was lost. Because UDP doesn't have a "connection" like TCP does, the sender doesn't know if the data is going anywhere and the receivers have no way of knowing if anything is being sent.
    Picture a radio station. A guy working the night shift hopes there is someone somewhere listening to his broadcast, but he doesn't know. Likewise, if you turn on a radio and hear nothing but static, you may be listening to a frequency where there are no stations broadcasting, or the station transmitter might be off the air, or there might be interference keeping you from hearing the signal, but again you don't know which.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Problem with issuing command via CustomScriptExtension

    I am trying to issue a CustomScriptExtension command to an Azure virtual machine from within my C# application. The CustomScriptExtension is installed in the VM and working. I verified this by issuing a test command via PowerShell. Essentially I am trying
    to execute what would be the equivalent to the PowerShell command Set-AzureVMCustomScriptExtension, but in code.
    Below is the code segment that I am having problems with:
    ComputeManagementClient client = new ComputeManagementClient(AzureSessionInfo.CloudCredentials);
    IList<ResourceExtensionReference> extReferences = new List<ResourceExtensionReference>();
    IList<ResourceExtensionParameterValue> extParamValues = new List<ResourceExtensionParameterValue>();
    string account = "{\"storageAccountName\":\"" + AzureSessionInfo.StorageAccount + "\",\"storageAccountKey\": \"" + AzureSessionInfo.StorageAccountKey + "\"}";
    string scriptfile = "{\"fileUris\": [\"" + "https://teststorageaccount.blob.core.windows.net/testcontainer" + "\"], \"commandToExecute\":\"powershell -ExecutionPolicy Unrestricted -file " + "ScriptName.ps1" + "\"}";
    byte[] bytes1 = System.Text.Encoding.UTF8.GetBytes(account);
    bytes1 = System.Text.Encoding.UTF8.GetBytes(account);
    string ScriptPrivateConfig = Convert.ToBase64String(bytes1);
    byte[] bytes2 = System.Text.Encoding.UTF8.GetBytes(scriptfile);
    bytes2 = System.Text.Encoding.UTF8.GetBytes(scriptfile);
    string ScriptPublicConfig = Convert.ToBase64String(bytes2);
    ResourceExtensionParameterValue extRef_Parameter1 = new ResourceExtensionParameterValue()
    Key = "CustomScriptExtensionPrivateConfigParameter",
    Value = ScriptPrivateConfig,
    Type = "Private"
    ResourceExtensionParameterValue extRef_Parameter2 = new ResourceExtensionParameterValue()
    Key = "CustomScriptExtensionPublicConfigParameter",
    Value = ScriptPublicConfig,
    Type = "Public"
    extParamValues.Add(extRef_Parameter1);
    extParamValues.Add(extRef_Parameter2);
    ResourceExtensionReference extRef_CustomScript = new ResourceExtensionReference
    Name = "CustomScriptExtension",
    Publisher = "Microsoft.Compute",
    Version = "*",
    ReferenceName = "CustomScriptExtension",
    ResourceExtensionParameterValues = extParamValues
    extReferences.Add(extRef_CustomScript);
    AzureSessionInfo.CloudServiceName = "CS1000001";
    AzureSessionInfo.VMName = "CS1000001";
    AzureSessionInfo.ImageFamilyName = "Windows Server 2012 R2 Datacenter";
    client.VirtualMachines.Update(AzureSessionInfo.CloudServiceName,
    AzureSessionInfo.VMName,
    AzureSessionInfo.VMName,
    new VirtualMachineUpdateParameters
    RoleName = AzureSessionInfo.VMName,
    ResourceExtensionReferences = extReferences
    I receive the following error message back from the call:
    BadRequest: Invalid extension reference parameter value in JSON configuration data for the Role: CS1000001, Reference name: CustomScriptExtension.
    I could only find very little documentation on this. Any help would be appreciated.

    Thanks Mekh... after many hours of researching and trial/error, I figured it out.
    The MSDN article I used previously led me down the wrong path. (see article here: http://msdn.microsoft.com/en-us/library/azure/dn781373.aspx). This may work for RESTful calls but not for .NET API calls.
    The part of the code that was hurting me was where the command strings (account and
    scriptfile) were being converted to Base64 encoding. This is NOT correct for .NET calls. Once I removed that, everything worked fine.
    I came across this after researching the same commands used by Linux scripts. They don't convert to Base64 either so I wonder why this is included in the documentation at all.
    In either case, I figured it out, but the documentation is very poor in this area (or all together non-existent). I don't even see where it is documented as to which JSON parameters names are supposed to be used, or even that JSON is required.
    Also, related to the Update command, if you are truly "updating" the config, you must include everything about the original config (whether it changed or not) along with the changes you want to make. If not then you will undo ALL but the changes
    you issued via the command.

  • Sending character array (as a bytebuffer) via udp

    Hi,
    I do have to send a udp packet, containing several variables, and the reciever awaits it as a character array ... (C++, cannot change this part!)
    As far as I see it, I can only send ByteBuffers via DatagramPackets via udp.
    Has anyone a clue how I can convert a ByteBuffer into another Bytebuffer in a way so that the udp reciever gets it as if I had sent a character array instead ?!?
    Or is there actually a character array udp sender ?!?
    Any help is highly appreciated, big Thanx in advance,
    ~Carmela

    In C++, char' are unsigned bytes. Thus converting between bytes and chars is fairly straight forward. Java treats char as unsigned short (16-bit) so it converts chars to bytes as UTF-8. (By default) Unless you are using special on ascii characters i.e. 128+ all this makes no difference whatsoever.
    A bytebuffer is just a container for bytes. You can encode anything as bytes so there is no magic here. Just get the data as bytes and put it into a ByteBuffer.
    String string = "text";
    ByteBuffer bb = ByteBuffer.wrap(string.getBytes());

  • Total nube to jws, need to run ssh command via web or jws?

    Ok So we had a developer that created this application that can basically run ssh commands via jws I believe. Unfortunately he is no longer here. I am wondering how you do this? I know tha commands that are already set up, but I have no idea how to implement it into my project.
    I am using Struts 2, Java 5, Weblogic 9.2, Spring
    Thanks
    orozcom

    Have a look at:
    http://www.jcraft.com/jsch/
    basically you'd need a small webstart client to wrap something like the above library. Best thing is to try with a standalone java client first. Once that is working have a look at turning it into a webstart app.

  • Can not send command via VISA test panel in MAX

    Hello all,
    I am having a small issue using the VISA test panel in MAX.  I am trying to send a simple command to a device and then retrieve the response data.  I am able to do this successfully via Labview, but for whatever reason I can not get a good response in MAX.  The command that I am sending is simply a letter (address of the device) followed by an end of line character (\r\n in ascii).  In MAX, I simply append the \r\n onto the string sent in the buffer (Send End on Writes == FALSE).  All serial settings are the same as what I have in LV (19.2, 8-n-1).  Does anyone have any thoughts?  This is kind of frustrating as I just want to do something simple and don't want to have to build a whole routine in LV to do this.
    Cheers, Matt
    Matt Richardson
    Certified LabVIEW Developer
    MSR Consulting, LLC
    Solved!
    Go to Solution.

    Thanks, Broken.  I am getting a time out error.  Clearing the buffers doesn't seem to be making a difference. This is baffling to me.  I must be missing something fundamental.
    Something that I didn't add before is that I seem to be able to send the command via labview without a read, and then read it via MAX.  This must have something to do with way it is sending the command.  Arrrrgh!
    Matt
    Matt Richardson
    Certified LabVIEW Developer
    MSR Consulting, LLC

  • Byte missing via Serial Communication

    Hi i am facing a prob of byte missing via serial communication.
    but for some application it's work fine.
    i am using net beans 5.5 ID

    the code that i am using is as under:
    public void connect() {
    ComChoose port = new ComChoose(); // Is used to select from diff port available in system
    CommPortIdentifier portId = port.getCommPort();
    System.out.println("portid"+portId);
    try {
    serialPort = (SerialPort) portId.open("Meter Parameter", 2000);
    } catch (PortInUseException e) {
    JOptionPane.showMessageDialog(this, e);
    try {
    inputStream = serialPort.getInputStream();
    outputStream = serialPort.getOutputStream();
    } catch (IOException e) {
    JOptionPane.showMessageDialog(this, e);
    try {
    serialPort.addEventListener(this);
    } catch (TooManyListenersException e) {}
    serialPort.notifyOnDataAvailable(true);
    try {
    serialPort.setSerialPortParams(4800,
    SerialPort.DATABITS_8,
    SerialPort.STOPBITS_1,
    SerialPort.PARITY_NONE);
    serialPort.setRTS(false);
    } catch (UnsupportedCommOperationException e) {}
    //Closing the serial Port
    public void closesr(){
    if (serialPort != null){
    serialPort.close();
    //Serial Event
    // &Ch[i] is the string array used to store bytes
    public void serialEvent(SerialPortEvent serialPortEvent) {
    switch (serialPortEvent.getEventType()) {
    case SerialPortEvent.BI:
    break;
    case SerialPortEvent.OE:
    break;
    case SerialPortEvent.FE:
    break;
    case SerialPortEvent.PE:
    break;
    case SerialPortEvent.CD:
    break;
    case SerialPortEvent.CTS:
    break;
    case SerialPortEvent.DSR:
    break;
    case SerialPortEvent.RI:
    break;
    case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
    // outputBufferEmpty(serialPortEvent);
    break;
    case SerialPortEvent.DATA_AVAILABLE:
    try {
    int numBytes = inputStream.read(readBuffer);
    for(int i=0;i<numBytes;i++){
    number =readBuffer[i] ;
    if(number<0){
    number=number+256;
    if(number==256){
    number=0;
    String r = Integer.toHexString(number);
    if(r.length()==2){
    ch1[k]=r; //K is an integer value defined globally K=0;
    } else{
    ch1[k]="0"+r;
    // System.out.println(ch1[k]);
    // System.out.println(k);
    k++;
    if(k >=200){
    System.out.println(k);
    k=0;
    serialPort.close();
    flag=true;
    } catch (Exception evt) {
    System.out.println(evt);
    serialPort.close();
    break;
    }

  • Sending commands via usb port?

    i'm looking to send commands over a usb cable to a device via xcode or cocoa. i know leopard did away with rs232 commands, so i'm looking for some sample code that sends a command via objective-c over a usb cable.

    From Cameron Forbes of US FTDI tech support:
    Ed:
    After you install the FTDI D2XX drivers for Mac OS X (Intel Macs):
    http://www.ftdichip.com/Drivers/D2XX/MacOSX/UniBin/Universal%20D2XX0.1.4.dmg
    Add the following links (from Mac OS X Installation Guide):
    · Start a Terminal session (Go > Applications > Utilities > Terminal)
    · Copy libftd2xx.0.1.0.dylib to the /usr/local/lib directory (cp Desktop/D2XX/bin/libftd2xx.0.1.0
    /usr/local/lib)
    · Change directory to the /usr/local/lib (cd /usr/local/lib)
    · Create a symbolic link to the library (ln -sf libftd2xx.0.1.0.dylib libftd2xx.dylib)
    The example code is located at:
    /desktop/d2xx/Samples
    Best Regards,
    Cameron Forbes
    Field Applications Engineer - Americas
    [email protected]
    Future Technology Devices International Ltd.
    7235 NW Evergreen Parkway
    Suite 600
    Hillsboro, OR 97124-5803
    Tel: 503.547.0988 xt 315
    Fax: 503.547.0987
    Practical USB Interface Solutions

  • Using parallel to invoke commands via schroot

    Expanding on the discussion here, why does starting commands via parallel into an schroot cause all the problems described?
    I can for example, stagger start a number of commands through schroot as long as they don't start at the same time with no problem.
    Example (each has been started one-at-a-time:
    % schroot -p -- nice -19 makepkg -s
    % schroot -p -- htop
    schroot -p -- mprime

    The solution is not to use schroot at all but to simply call chroot directly via parallel which works fine.
    Example worker code for parallel.  See the complete build script for more.
    % sudo linux32 chroot --userspec=1000:100 /opt/arch32 /bin/bash -c 'cd $here ; nice -19 makepkg -scd --skipinteg --config $HOME/bin/repo/makepkg.i686'

  • Transferring primitive data types via UDP other than a String

    Hi ALL,
    I am new to Socket programming in UDP.
    I need to implement a FTP client-server application.
    Now the packet that I need to transfer using UDP as a DatagramPacket consists of multiple primitive data types, (3short types and 1 byte array of size 265.)
    How do I do that?
    All the samples and examples I managed to find on the Internet illustrated the problem of transferring a String type converted to getBytes and the byteArray is transferred.
    However, in my case i need to pass this structure..(3fields) to the other side. If I convert the 4 fields to a single concatenated string there's this problem of finding out where each of the four fields begin and where do they end.
    Please suggest and help...
    thanks..
    : )

    Just create a class that represents your structure and convert-it to a byte array that can be sended over a DatagramSocket.
    Try this sample code :
    import java.io.*;
    import java.net.*;
    public class DP
        /** Creates a new instance of DP */
        public DP ()
         * @param args the command line arguments
        public static void main (String[] args)
            try
                System.out.println ("Starting server ...");
                DatagramServerThread server = new DatagramServerThread ("Datagram server");
                server.start ();
                System.out.println ("Creating your object ...");
                ByteArrayOutputStream baos = new ByteArrayOutputStream (); // Creating byte array output stream ..
                ObjectOutputStream oos = new ObjectOutputStream (baos);// Creating a object output stream that writes to byte array output stream..
                YourStructure newObject = new YourStructure (); // creating your data structure..
                newObject.setShortField1 ((short)12);// setting values ...
                newObject.setShortField2 ((short)45);
                newObject.setShortField3 ((short)4);
                newObject.setArray (new byte [256]);
                oos.writeObject (newObject); // write your structure to object output stream...
                byte data_to_be_sent[] = baos.toByteArray (); // retrieving equivalent byte array...
                // send data...
                DatagramSocket s = new DatagramSocket ();
                System.out.println ("Sending ...");
                DatagramPacket packet = new DatagramPacket (data_to_be_sent, data_to_be_sent.length);
                packet.setAddress (InetAddress.getByName ("localhost"));
                packet.setPort (8888);
                s.send (packet);
            catch (Exception e)
                e.printStackTrace ();
    class YourStructure implements Serializable
         * Holds value of property shortField1.
        private short shortField1;
         * Holds value of property shortField2.
        private short shortField2;
         * Holds value of property shortField3.
        private short shortField3;
         * Holds value of property array.
        private byte[] array;
         * Getter for property shortField1.
         * @return Value of property shortField1.
        public short getShortField1 ()
            return this.shortField1;
         * Setter for property shortField1.
         * @param shortField1 New value of property shortField1.
        public void setShortField1 (short shortField1)
            this.shortField1 = shortField1;
         * Getter for property shortField2.
         * @return Value of property shortField2.
        public short getShortField2 ()
            return this.shortField2;
         * Setter for property shortField2.
         * @param shortField2 New value of property shortField2.
        public void setShortField2 (short shortField2)
            this.shortField2 = shortField2;
         * Getter for property shortField3.
         * @return Value of property shortField3.
        public short getShortField3 ()
            return this.shortField3;
         * Setter for property shortField3.
         * @param shortField3 New value of property shortField3.
        public void setShortField3 (short shortField3)
            this.shortField3 = shortField3;
         * Getter for property array.
         * @return Value of property array.
        public byte[] getArray ()
            return this.array;
         * Setter for property array.
         * @param array New value of property array.
        public void setArray (byte[] array)
            this.array = array;
        public String toString ()
            StringBuffer buffer = new StringBuffer ();
            buffer.append ("Short field 1 is ");
            buffer.append(this.getShortField1 ());
            buffer.append ("\nShort field 2 is ");
            buffer.append (this.getShortField2 ());
            buffer.append ("\nShort field 3 is ");
            buffer.append (this.getShortField3 ());
            buffer.append ("\nYour array field is ");
            for (int index = 0; index < this.getArray ().length; index++)
                buffer.append ("Index [" + index + "] = " + this.getArray () [index] + "\n");
            return buffer.toString ();
    class DatagramServerThread extends Thread
        protected DatagramSocket socket = null;
        public DatagramServerThread (String name) throws IOException
            super (name);
            socket = new DatagramSocket (8888);
        public void run ()
            try
                byte buffer [] = new byte [socket.getReceiveBufferSize ()];
                DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
                System.out.println ("Server is ready. Waiting for packet ...");
                socket.receive(packet); // waiting for packet ...
                System.out.println ("Packet received! : ");
                byte received_data[] = packet.getData ();
                ByteArrayInputStream bais = new ByteArrayInputStream (received_data); // Creating byte array input stream ..
                ObjectInputStream ois = new ObjectInputStream (bais); // Creting Object input stream
                Object readed_object = ois.readObject ();
                YourStructure your_original_object = (YourStructure)readed_object;
                System.out.println (your_original_object.toString ());
                System.out.println ("Exiting server thread. Bye");
                socket.close ();
            catch (Exception e)
                System.err.println ("Server error");
                e.printStackTrace ();
    }

  • Inconsistent results from hostname Unix command via ARD

    I sometimes get the DNS name and sometimes get the local sharing name.
    Some one pointed out to me
    % scutil --set HostName DNS-name
    as root will do the job.
    So the next question is can one get the Mac to cough up its DNS name or
    IP address without major acrobatics.
    For example
    % ifconfig en0 inet
    gives the IP address but you have to parse it out and
    % host IP-address
    will give the DNS name but again you have to parse it out.

    We have a bunch of machines that are all named via the Sharing panel in System Preferences. Our network is giving them a different DNS name. We'd like to be able to access the Sharing name via the command-line (hostname gives DNS name). I assume this is possible because Remote Desktop seems to get it somehow.

  • UNIX command via Java?

    Hello all,
    one of the useful commands in unix is sed
    I would like to use the functionality of sed in Java.
    Is there any free java api where I can send a command like
    sed -n pos1,pos2p filenamethanks
    Aykut

    @tschodt
    Well, you failed to mention that...I spend at least 5hours about writing an efficient Java code for big text file.
    Within this time I read 50 to 100 forum threads from other people who had the same problem.
    All these pages I had found via google. Do you want me to write everything, all actions I did? :-) I don't think so.
    Is everyone else happy to use Runtime.exec() to invoke "sed"? How should I know that? :-) I am not a java expert.
    The idea of forums generally is, to share knowledge with other people.
    Well, after you said that, I will use Runtime.exec() and invoke sed and read the results.
    If you think you really need a full Java implementation of sed and
    you have not been able to locate one, you could always write one yourself...I don't need a full Java implementation of sed, not really.
    But just because I didn't find it, does not mean for me, that this code is no where exists.
    First I try to write the code by myself, second, I try to find it on internet by searching in google.
    If I still have no solution, I write my problem here at sun-java-forum (sometimes also somewhere else :-) )
    It seems to me you are angry, no need to be ...

  • Copy Command via RTS

    I access an accounting system via a remote terminal service and need to copy some error messages from time to time. When these messages are relatively short I just use the GRAB application. However, I need to be able to copy a longer message from time to time (that is larger than the small error/notes window). Command C doesn't work and the Apple version of the right click function doesn't either.
    I suspect this is a very simple matter that I am missing.
    Thanks in advance,
    Chris

    I don't use a RTS client but I found this thread, it may help, it is an earlier version of Cord but perhaps the bug as not been fixed yet.
    http://sourceforge.net/apps/trac/cord/ticket/229

  • Passing DB2 commands via cfquery

    Hi-
    Does anyone know how to pass DB2 command(s) via a cfquery?
    I've been tasked with getting a SQL query into Coldfusion
    that uses - what looks to me - like a native DB2 command. (The DB2
    EXPORT command takes data specified from a query and writes a
    formatted file.) Specifically, I need to pass a query via
    <cfquery> that looks something like:
    <cfquery...>
    EXPORT TO file.out
    OF DEL MODIFIED BY STRIPLZEROS
    SELECT
    select statement here
    </cfquery>
    I'm kinda thinking that if you know how to "escape" the
    native commands in a cfquery that might work, but for now when I
    pass the above query it errors out on me.
    Anyone?
    Thanks,
    Rich

    rich.leach wrote:
    > Hi-
    >
    > Does anyone know how to pass DB2 command(s) via a
    cfquery?
    >
    > I've been tasked with getting a SQL query into
    Coldfusion that uses - what
    > looks to me - like a native DB2 command. (The DB2 EXPORT
    command takes data
    > specified from a query and writes a formatted file.)
    Specifically, I need to
    > pass a query via <cfquery> that looks something
    like:
    >
    > <cfquery...>
    > EXPORT TO file.out
    > OF DEL MODIFIED BY STRIPLZEROS
    > SELECT
    > select statement here
    > </cfquery>
    >
    > I'm kinda thinking that if you know how to "escape" the
    native commands in a
    > cfquery that might work, but for now when I pass the
    above query it errors out
    > on me.
    >
    > Anyone?
    >
    > Thanks,
    >
    > Rich
    In general you just pass it in, just like you tried. All the
    <cfquery
    ...> tag is wrap everything inside it up and passes it to
    the database
    as the string it is.
    What you very likely are running into a limitation of the
    database
    driver between ColdFusion and your database. It may not be
    able to
    handle this command and|or the type of result it returns.
    Checking on
    the drivers capabilities and|or alternate choices maybe
    required.
    Alternatively, does DB2 support some type of stored
    procedure? Can you
    write this code in the database and just call it with
    <cfquery ...> or
    <cfstoredprocedure...> tags?

  • UNIX crypt command via SM69

    Hello,
    I'm trying to execute the CRYPT command from SM69.
    From cmd line the following works
    crypt TEST <FILE1.txt >FILE2.txt
    Anyone get this to work?

    @tschodt
    Well, you failed to mention that...I spend at least 5hours about writing an efficient Java code for big text file.
    Within this time I read 50 to 100 forum threads from other people who had the same problem.
    All these pages I had found via google. Do you want me to write everything, all actions I did? :-) I don't think so.
    Is everyone else happy to use Runtime.exec() to invoke "sed"? How should I know that? :-) I am not a java expert.
    The idea of forums generally is, to share knowledge with other people.
    Well, after you said that, I will use Runtime.exec() and invoke sed and read the results.
    If you think you really need a full Java implementation of sed and
    you have not been able to locate one, you could always write one yourself...I don't need a full Java implementation of sed, not really.
    But just because I didn't find it, does not mean for me, that this code is no where exists.
    First I try to write the code by myself, second, I try to find it on internet by searching in google.
    If I still have no solution, I write my problem here at sun-java-forum (sometimes also somewhere else :-) )
    It seems to me you are angry, no need to be ...

Maybe you are looking for