How to convert an array of bytes in a single integer

Hello!

So, for the moment, I am trying to receive data from a device that sends data back as an array of 10 bytes, where the first 2 bytes are a header, 6 are a number of words that is supposed to be a unique 48-bit value and the last 2 are a number of errors which is suppose to be a unique 16-bit value.

Ex:

Word has received

(Header)   (----------------------------------Word Count------------------------------)   (Number of errors)
0            120     0               44              221          155          96             48             0              0

So, in theory, what I want to do is be able to calculate the values like this:

(Header)   (----------------------------------Word Count------------------------------)   (Number of errors)
0            120     0               44              221          155          96             48             0              0
The binary values: 00000000 00101100 11011101 10011011 01100000 00110000 00000000 00000000
Concat. Vals: 000000000010110011011101100110110110000000110000 0000000000000000
Calc'd Vals: = 192696508464 words = 0 errors
* 40 (40-bit words)
Totals: = 7.7078603e + 12 bits total = 0 Total errors

But the problem that I am running is that all methods that I use seem to not be correct.

I tried:

Flatten the data and then it unflattening like a U64

Convering to bool, concatinating tables data, and then convert that to a certain number

Join all the bytes together using the join function

Casting to an array of bytes to a U64

And with all methods, the data that I use is incorrect (in the sense where the values are incorrect compared to this calculation manually like I did above), and at this point, I'm not sure how to get the correct values, so any kind of help would be greatly appreciated!

Thank you!

It seems to work for me...

Tags: NI Software

Similar Questions

  • How to convert a string to byte array

    Hello

    I want to convert a string with a hexadecimal number in the array of bytes, this string includes a cutting-edge information, but I don't want to add this tip to arry bytes.

    detailed information please see the photo. I hope someone can give me some instructions, thank you very much.

    The accepted solution of Giedrius.S is not correct, based on the image shown in the first post. That the solution will not eliminate the spaces before the tip, and the string to byte array to convert individual characters '0', '8', 'space', '9', etc. for them to byte values. The right solution, based on the image below:

  • What is the best way to convert an array of bytes or string cluster

    I am writing a program that sends UDP packets and I defined the data I want to send via large groups (with numbers of u8, u16/u32, u16/u8/u32 tables and nested groups). Just before sending the data, I need to convert groups or chains of arrays of bytes. The flatten the string function is almost perfect for this. However, it is addition of lengths in the tables and strings that makes this unusable method, because as far as I can tell.

    As I have many of these groups, I would rather not hard code the unbundle names and conversion/cast of strings or arrays of bytes for each of them.

    Y at - it a function, or a tool that I'm on?

    Thank you!

    mkirzon wrote:

    The program I'm developing is to communicate and to poll an external device that includes a Protocol well documented. The messages that I built in clusters contain components accurate that expected from the other device. So, if my program adds any additional info (such as this array/string lengths), monitor the device external won't recognize messages and returns an error.

    Unfortunately, you have to ungroup your cluster and collect the individual channels to concatinate.

  • How to convert table 1 d of the only single

    Hye, I am brand new in Labview. Can someone help me how to convert arrray 1 d of the only sin

    GLE.

    Use Index

  • How to convert an array of char byte array?

    Hello

    Someone can say, how can I convert Byte char []?

    Thank you

    What:

    data Byte [] =...

    Char [] charArr = (new String (data)) .toCharArray ();

    Rab

  • How to convert to unsigned int byte array?

    Greetings,

    I have no particular knowledge of Java programming, and I have a problem with a conversion.

    The exception thrown is "number Format Exception for the input string:"249"when I run the following code:

    ReadBytes = SocketInput.Read (bMessage);
    NetMessage = new String (bMessage);
    NetMessage = NetMessage.substring (0, readbytes);

    If (NetMessage.Equals ("NORES"))
    NetMessage = '0 '.

    int Res = 0;
    Try
    {
    RES = Byte.valueOf (NetMessage);
    }
    catch (NumberFormatException nfe)
    {
    AddMessage ("Number Format Exception" + nfe.getMessage () + "[" + bMessage.toString () + "]");
    }

    The java Byte / byte data type is signed and contains values from-128 to 127. Why not use Integer.valueOf () instead (which is not signed or said by the way) and look
    [url http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html] in Java primitive data types.

    In your code example, there is no byte (byte []) array, while mention you in the subject...

  • How to convert an array of string elements to a cluster with elements named different data types?

    I'm looking for more help with the conversion of an array of elements of the chain in a cluster containing elements named different data types.

    I am importing data from an Excel worksheet.  He is coming in LabVIEW as separate (channels) 3 tables: 1) Variable name, (2) three possibilities Int, double, String) data type and the value 3), with the clues in each table corresponding to a separate variable (I have about 180 variables to import).  My ultimate goal is to convert the string array of 'Value' in a cluster.  But I want the correct data type in the cluster and I also the elements of the cluster name to match with the string 'Variable name' table so that I can use the Unbundle based on the name in my main VI.

    Please see attachment a Subvi for more details.  I did the size of the new items of tables 5 for simplicity.   I realize that labels property cannot be changed during execution and I don't think I need to do.  I just want to use the production cluster (mainly the unbundle by name) to help design my main VI.  I will need to 'read' and 'write for' the cluster during execution, but I won't need to change the names of the items.

    I was also wondering if there is a better way to import data from Excel?  Is it possible to import directly into a cluster immediately rather than put everything as strings?  I have attached a Subvi showing how I currently bring in data (found on the forum somewhere).  It comes as table 2D, which I divided into 3 separate tables that I mention above.

    I am open to any suggestion.  Thank you very much.

    -Mike

    Instead of trying to create a cluster, I think I would use only variant attributes.

  • How to convert the array of integer to string

    Hi, I'm trying to convert the table of 32-bit integers to a string. For ex: If the array contains {1234, 4567, 8, 9} I need string like {00.00, 34,12, 00, 00, 45, 67,...}

    How to do this one.

    Help, please

    Thank you best regards &,.

    Harish. G.

    Hi Haris,

    use the above solution as it seems you really want figures BCD...

    Or this slightly improved version:

  • How to convert the value of byte in two asci characters

    I have a problem that is perhaps easy to solve, but I do not know the answer.

    Is it possible to convert a value of binary characters byte two asci.

    For example:

    There is a 8-bit value, 0.

    I want to have two characters distinct ASCI (string). 0 and has.

    Thanks for any help.

    I have the solution. Sorry to ask this question.

    Convert this byte with 'Number of hexadecimal string', separate this string in two characters and ready is.

  • How to convert an array into a cluster of the same type as the one used to build the table previously?

    I have a group of 6 items I need to change in a table for the part of the VI process.  What I can do, but then I need to change in a cluster of the same type to be used elsewhere.  When I change the table in a cluster, I find myself with a cluster of 9 elements, which of course is not compatible!

    I am attaching snapshots of context-sensitive help in the initial cluster, the intermediate table and the final cluster (bad).  Regarding the photos, the length of the 1 d tables and values in their midst are the only subject to change things.

    Please could someone help by suggesting ways to work around this problem.  Thank you

    Please do not post bitmaps by chaning simply .jpg file name extension. Do not change the file type. There is a good reason why the forums software does not bitmaps, and this is because the file sizes are huge.

    To your question: right click on the table of the Cluster service and select 'Size of Cluster' in the context menu to set the size of the cluster of output.

  • How to convert to pdf w / spreads, but print single pages?

    I need to convert a brochure in PDF for distribution using spreads.  However, I would like the pdf to print using unique pages.  Anyone know how I can do this?  I tried all kinds of settings and don't see where I can put it up in this way.  I use by way CS4,.

    Thank you

    Mel

    If you mean you want the PDF file to spread, you define only from Acrobat. There is no way I know (someone else can correct me if I'm wrong) to set the default value from the view of export in InDesign. After exporting PDF, open it in Acrobat Pro and set your display under file/properties/initial view settings and resave the PDF file.

  • Array of bytes to double signs for AutoPowerSpectrum

    I'm trying to analyze a wav file and get the thd.

    During the read wav file, I read in one data (void *) table.  And according to the type of bit, depends on how to call PlotWaveform.  So, in my example, I have a 16-bit mono signal.  And I'm calling draw the waveform as follows:

    PlotWaveform (panelHandle, PANEL_CHANNEL_LEFT, channel1, samplesPerChannel, type, 1.0, 0.0, 0.0, 1.0, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1,
                            VAL_RED);
    

    And a perfect sine wav out.

    Now, I try to do the THD on the signal, but can't convert my array of bytes in a double table.  I have the following code, but all my values that I use are in power - 319th.

    channel 1 is a (void *)

    I guess that the ConvertArrayType () function can help you in this problem.

  • Array of bytes to bitmap

    I'm trying to convert an array of bytes into a bitmap image.  The byte array returned from a url, if you enter the url in Internet Explorer, it is automatically returned.  What would be the best way to get the data returned by the url, and how would it be better to convert as bitmap?

    There is an example here:

    http://www.coderholic.com/BlackBerry-webbitmapfield/

  • Convert 2D array of strings of digits in decimal table 2D

    How to convert an array of strings of decimal places decimal table 2D 2D?

    Thanks in advance

    -DP

    BatchTest Corp.

    NEITHER Alliance Partner

  • Array of bytes and KSOAP2

    Hello
    I have a request. I have a MSSQL database into two columns. One is a varchar and the second is the Image type. I would use these two fields filled to KSOAP2. I tried to send a picture in KSOAP byte array but it did not, probably, I sometimes confuse.
    Here is the source code.

    public byte[] getBytesFromBitmap(Bitmap bmp) {
     try {
      int height=bmp.getHeight();
      int width=bmp.getWidth();
      int[] rgbdata = new int[width*height];
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      DataOutputStream dos = new DataOutputStream(bos);
      bmp.getARGB(rgbdata,0,width,0,0,width,height);
      for (int i = 0; i < rgbdata.length ; i++) {
       if (rgbdata[i] != -1) {
        dos.writeInt(i);
        dos.flush();
        //l++;
       }
      }
      bos.flush();
      return bos.toByteArray();
     } catch (Exception ex) {
      Dialog.alert("getBytesFromBitmap: " + ex.toString()); return null;
     }
    }
    
    Bitmap borderBitmap = Bitmap.getBitmapResource("rounded.png");
    byte[] img = getBytesFromBitmap(borderBitmap);
    String name = "Name";
    SoapObject rpc = new SoapObject(serviceNamespace, "name");
    
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    rpc.addProperty("_img", img);
    rpc.addProperty("_string", name);
    envelope.setOutputSoapObject(rpc);
    envelope.bodyOut = rpc;
    envelope.dotNet = true;
    envelope.encodingStyle = SoapSerializationEnvelope.XSD;
    

    I also tried... I transferred the image in the array of bytes to a string, using the string, I sent KSOAP and everything went well... The problem was that if she string converted to array of bytes, and then in a Bitmap, then bb do not show Bitmap. I would like to send a byte array.

    Thank you

    Stepan

    This function is useful to get the bytes of the image.

    public static byte[] returnByte(String path)
    {
    FileConnection fconn;
    int available = 0;
    InputStream input = null;
    byte[] data=null;
    try
    {
    fconn = (FileConnection)Connector.open(path);
    if(fconn.exists()==true)
    {
    input = fconn.openInputStream();
    available = input.available();
    int fSz = (int)fconn.fileSize();
    data = new byte[fSz];
    input.read(data, 0, fSz);
    }
    }
    catch(Exception e)
    {
    Dialog.alert("Error");
    }
    return data;
    }
    

    Now you must do this:

    Byte [] img = returnByte ("pawan.png");

    rpc.addProperty("_img", Base64.encode(img));
    

    I'm sure it works...

    Thank you

Maybe you are looking for

  • Hover bookmarks in FF 18.0 uses 100% of 1 core

    After update to 18.0 noticed lag in hover bookmarks (menu drop-down). Checked in the Task Manager: hovering bookmarks CPU usage stands at 25%, which is for my quad exactly 1 kernel used 100%. Stop moving mouse lowering of this value to 0%.

  • Z400 workstation (6 DIMMs) and Xeon X 5687

    taken in charge or incompatible?

  • Installation of LabVIEW Runtime Engine 2016 compatibility questions...?

    Hi, I have just a quick question... I just download LabVIEW Runtime Engine 2016 in a PC at work. I need to run a VI in this PC that has a few executables 2015 VI for the moment. My question is, if I install the runtime from 2016: Will there be any pr

  • substitute dv9700 videocard mother questions map

    I got my laptop diagnosed today and the result is that I think I need to get my motherboard replaced. I bought it with a processor Intel Core Duo of 2.5 G and a 512 MB nVidia graphics card (I think a discreet 8600) - the two options the best availabl

  • Install the printer (Canon MF 4320-4350) on laptop

    Hello Robert Chettri,. Thanks for the reply to my email and answering my question. I have desktop and printer installed on my office was ok.  I bought the new laptop and tried to get my office printer and installed on my laptop.  I disconnected the c