Hex string to hex array

Hello,
I have a hex string that contains the address then word:
0 8E39
1 60E3
2  1B
3  42
4  100
5  0
I am trying to generate two arrays, one with the address in two bytes and the other with the word in four bytes so that I will end up:
00 8E39
01 60E3
02 001B
03 0042
04 0100
05 0000
Any help will be greatly appreciated!
Thanks,
hiNi.
Solved!
Go to Solution.
Attachments:
hex_word_with_addr.txt ‏1 KB
string to array.vi ‏13 KB

You can also directly use "read from spreadsheet file" (but you need to convert to U16 later).
hiNI wrote:
I am trying to generate two arrays, one with the address in two bytes and the other with the word in four bytes so that I will end up:
You said you wanted two arrays, so you still need to slice out the two columns.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
string to arrayMOD.vi ‏17 KB
stringToArrayMOD.png ‏28 KB

Similar Messages

  • Convert HEX String into HEX Array

    Hi!
    Probably a silly question, but I am looking for a way to convert a ROM ID number such as "5E03C21000BA" into an short hexadecimal array.
    The way to do this in C would probably be
    char[17] str_romID = "5E03C21000BA";
    uchar[8] romID;
    sscanf(str_romID, "%02X%02X%02X%02X%02X%02X%02X%02X",
    &romID[0], &romID[1], &romID[2], &romID[3],
    &romID[4], &romID[5], &romID[6], &romID[7]);
    but I can't seem to find a way to do this in LabVIEW. I would be very grateful if you could help me out with a sample program. Thanks ever so much!
    Stefan

    Hello Blondchen,
    I have attached a picture to my last explanation. This example doesn't take care of strings with an uneven number of chars!
    My array has only 6 numbers as you only gave a string with 12 chars... That's what I asked before: how should we know where to split your string to the single numbers? Normally I would take 2 chars to form a byte (as I did in the example). If you give me 16 chars I give you 8 bytes...
    I also think your C byte array will be an U8 array in LabView. If you REALLY need I8 numbers you can change the default type of the "hex to string" or cast to I8 (advanced->data manipulation->type cast) after the conversion.
    Best regards,
    GerdW
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    ConvertHexHex.png ‏13 KB

  • Boolean Array to Hex String - LabVIEW Supplementary Data Conversion Library in version 12 please

    Hello,
    I would like to use the Boolean Array to Hex String.vi in LabVIEW Supplementary Data Conversion Library at http://zone.ni.com/devzone/cda/epd/p/id/3727
    But it is version 4. Can someone give me the library in version 12? Attached herewith.
    Attachments:
    cnvrsion.zip ‏38 KB

    Mass compiled in 8.2.1, which you can open with 2012.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    convrzun.llb ‏65 KB

  • I want to communicate a RS485/2-wire device through COM1. I tried Instrument I/O Assistance to write to COM1(hex string with or without end bye:0D0A), something happened on the bus, but is not defirrential signal, and device didn't recognised them.

    I am new to LabView, so please bear with me...
    I tried to communicate with an RS485/2-wire device through COM1.  I used Instrument I/O Assistant (and Advanced/Basic Serial Write and Read examples) to write command (HEX string) to COM1,  
    tried writing HEX strings with and withour end bye (is 0D0A the correct end signal for HEX string?).  Both didn't get device's responce.  Looks like the device didn't recognize the command.
    I monitored the transmitted signals on the bus, they were not differential as supposed to be.....
    What is the possible reason to cause this? Please help...
    The hardware connection is OK, because I am able to communicate with the device through COM1 (with the same command) using different software application.

    How are you sending the hex? Is your string control set for hex display or normal? If it's set for normal, then if you send something like 'AD', then you aer sending the ASCII characters 'A' and 'D' and that's not the same thing. I don't believe the I/O assistant can send hex but you can modify the basic serial write and read to do so. Just right click on the string control and select 'Hex Display'. You can also enter the data in a numeric control (set for dex display) and use a type cast or an array of U8's and use the Byte Array to String function. Hex data usually doesn't use any kind of termination characters such as CR/LF.
    If communication is working with another app, then as you said, the hardware is okay and it's not a problem with differential signaling.

  • How can I convert a string of hex values to a hex format string programatically?

    Is there a way to convert a string of the following format:
    1400010107070D0305006A01 ........           ("Normal display" string)
    programatically to:
    1400 0101 0707 0D03 05006A01 ..........      ("Hex display" striing)
    I need to do this in order to calculate a CRC16 value.
    See attached VIs
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    CMM_SN_MULTI.vi ‏50 KB
    CMM_CRC16_Calculator.vi ‏23 KB

    You can iterate over the string and use the String to Hex VI. If you work with two bytes of the string at a time you can get a U8 array of the desired binary values. Then when you are complete you can either work with the byte array of convert it back to a string using Byte Array to String.
    EDIT: GerdW typed faster than I did.
    Message Edited by Mark Yedinak on 03-18-2010 02:55 PM
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • BIG ASCII string to HEX string

    Hello guys,
    I know that is already a lot of posts regarding this issue, but I couldn't find exactly what I need and also couldn't manage to solve it myself...
    I need to convert a string with ASCII characters to a string containing HEX representation of these characters.
    What I did was: 
    Apparently it works very well, but only for a limited numbers of characters, defined by data representation of the 0 constant (U64). It allows me to convert only 8 ASCII characters, as you can see on the image below:
    So, it converted from 0 to 7, but not the remaining characters (8 and 9).
    Any ideas??
    Thanks in advance!
     

    What is the data type of the constant wired into the typecast.  My guess is it is a U64.  So it will only typecast the first 8 bytes of your string to a number, then you are doing hex on those 8 numbers.
    Use the function String to Byte Array.  Or you could also typecast where an array of U8 integers is wired into the typecast function.

  • Which bytes should be edited in a WMF hex string stored in an RTF file in order to change image dimensions?

    I  would like to save the WMF file with proper dimensions as they are in the editor (my saved WMFs have the dimensions of my screen resolution).  They come from a RichEdit.
    Thanks.
    Edit:
    My goal is to convert the images that appear on a RichEdit to another format.
    Here is the fragment of the RTF:
    {\pict\wmetafile8\picw7407\pich9259\picwgoal4199\pichgoal5249 
    010009000003703e020000005a3e02000000050000000b0200000000050000000c022b24ef1c5a
    ffffffffffffff030000000000
    }\cf2\lang1033\b\f1\fs23\par
    For each 2 chars in this string I converted it to hex and saved it through a memory stream. Then I opened it in Paint or GIMP and there is the image.  I even can convert it to a PNG file through ImageMagick tool. But the dimensions are wrong. How to fix
    this?
    I am using Lazarus.
    I could guess that the header is not OK, but how they can be opened by Paint and converted? So I guess the dimensions info is wrong in the header. In GIMP even the dimensions are right, here a link to the GIMP's dialogbox confirmation with the dimensions
    it has encountered in the file (  http://s13.postimg.org/s536tgo9z/Metafile_in_GIMP.png  ).
    So the info is there, but is wrong. When I open the images in Paint, they are wrong. Microsoft Office Picture Manager can also open them correctly, but could not convert them so. I need to do it programmatically. TMetafile Delphi class could not open these
    files as well in order to be converted. So I could only edit the bytes.
    My RichEdit WMF data can not be accepted by ComputeAldusChecksum routine nor get a handle from SetWinMetaFileBits API call, which would convert it to an EMF format.
    procedure TMetafile.ReadWMFStream(Stream: TStream; Length: Longint);
    var
    WMF: TMetafileHeader;
    BitMem: Pointer;
    MFP: TMetaFilePict;
    begin
    NewImage;
    Stream.Read(WMF, SizeOf(WMF));
    if (WMF.Key <> WMFKEY) or (ComputeAldusChecksum(WMF) <> WMF.CheckSum) then
    raise EComponentError.Create('Invalid metafile.'); // <<<<<<<<<<<<<<< exception here
    Dec(Length, SizeOf(WMF));
    GetMem(Bitmem, Length);
    with FImage do
    try
    Stream.Read(BitMem^, Length);
    FImage.FInch := WMF.Inch;
    if WMF.Inch = 0 then
    WMF.Inch := 96;
    FWidth := MulDiv(WMF.Box.Right - WMF.Box.Left,25400,WMF.Inch);
    FHeight := MulDiv(WMF.Box.Bottom - WMF.Box.Top,25400,WMF.Inch);
    with MFP do
    begin
    MM := MM_ANISOTROPIC;
    xExt := 0;
    yExt := 0;
    hmf := 0;
    end;
    FHandle := SetWinMetaFileBits(Length, BitMem, 0, MFP); 
    if FHandle = 0 then
    raise EComponentError.Create('Invalid metafile.'); // <<<<<<<<<<<<<< exception here
    Enhanced := False;
    finally
    Freemem(BitMem, Length);
    end;
    end;

    Hi Antônio G,
    Based on your description, I’m afraid that it is not the correct forum for this issue, since this forum is to discuss:
    Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.
    To make this issue clearly, would you mind letting us know more information about this issue? Which language are you using? Which kind of app are you developing?
    Reference:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/a9e1857d-dd5b-443b-8633-397aea6e7b8c/help-on-properly-handling-wmf-mmanisotropic-image-in-rtf-file-when-extracted?forum=csharpgeneral
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/5b99d331-ef56-4d60-bf12-3e3b70783376/how-to-convert-a-hex-string-save-in-a-rtf-file-into-an-image-jpg-or-bmp?forum=csharpgeneral#a9219408-f73b-4e98-a9d8-7a1e0f20cdd9
    Maybe you could select the language development forum for this kind of issue. If not, please let me know more information about it, I will help you find a more appropriate forum.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Converting a Hex String to an Int

    I have a quick question. I am attempting to encode an Integer as a Hex String using Integer.toHexString(), which produces a max of eight hex characters.
    I then need to convert this string back to an integer. I tried using Integer.parseInt(string, 16), but this only works for positive integers, because it expects a negative number to be designated with a "-" sign, which is the behavior of Integer.toString(int, 16).
    I do not wish to represent the "-" sign in that manner, because I want to minimize the length of the hex string.
    This method is time-critical, and I would like it to be as simple as possible, so I am looking for a solution in the standard libraries. Does anybody know of a method to convert the eight character hex representation which includes the sign bit as part of the eighth character back to an int using a method provided by the libraries?

    int intVal = (int)Long.parseLong(str, 16);

  • How could I choose some bytes from HEX string and then convert it to a decimal value?

    Hi I am working with an OMRON E5EN temperature controller using VISA serial to get data, I send the Read from Variable Area command and get this string  in hexa 0230 3130 3030 3030 3130 3130 3030 3030 3030 3030 3041 3203 71 or .01000001010000000000A2.q in ASCII this string means:
    02 STX
    3031 3030 Node and subadress
    3030 End Code Normal Completion
    3031 3031 Command Read from Variable Area
    3030 3030 respt code Normal completion
    3030 3030 3030 4132 Hexadecimal A2 = 162  (this is the temperature data that I want to show in decimal)
    03 ETX
    71 Block Check Character
    I want to choose the eight bytes for the temperature data and convert it to a decimal number. I have seen the examples to convert a Hexa string to decimal but I do not know how to choose the specifics bytes that I need.
    I have look for a driver but i didn´t find any. I am a beginner so please include especific topics for me to study in your answer.
    Thanks
    Carlos Fuentes Silva Queretaro Mexico 

    If the response always has the temperature starting with byte 15 and is always 8 bytes in length, you can use the String Subset function to get those bytes out of the string.  Then use Hex String to Number to convert to a decimal number.
    Well someone already beat me to the solution:
    Message Edited by tbob on 01-04-2008 04:42 PM
    - tbob
    Inventor of the WORM Global
    Attachments:
    HexStr2Decimal.png ‏7 KB

  • Converting Hex string to unicode

    I am reading in a hex representation of Unicode characters as a string.(for example: 004100200042)
    I want to convert the string from hex to unicode, and write the corresponding characters to a file. The output should look like follow:
    A B (0041 = Capital A, 0020 = space, 0042 = Capital B)
    Could you please assist?

    Problem solved, no need to look into it. Thank you

  • Non-hex character in hex string after upgrade to Yosemite

    Hi,
    When I try to open some of my files I get an error: "Acrobat PDF File Format is having difficulties. Non-hex character in a hex string". I could open the files before.
    The only thing I've done since I opened the file last was to upgrade to Yosemite. The error occurs on both my Mac Pro (late 2013) and Mac Book Pro with Yosemite. Unfortunately, I have no access to a Mac with Mavericks and CS6 but I will try to fix one to verify that the file works there.
    Affected files  (Created in Illustrator CS6 on Mavericks):
    services.ai
    visual guidelines v.0.4.pdf
    visual guidelines.ai
    Tested steps:
    Open previous versions of the same file from our repository
    Update Illustrator CS6 to latest version
    Download Illustrator CC
    Tried to Place the file into another file (same error)
    Tried to repair file Enable content recovery mode | Illustrator CS2-CS5

    Hi svepdesigncenter,
    How you are accessing those files from your repository?
    There might be chances of getting files corrupted when transferring.
    File may have been sent as ascii when it should have been sent as binary or vice versa.
    In 99% of transfers it's ALWAYS safest to zip an AI or eps file before sending it anywhere.
    Regards,
    Sumit Singh

  • Non-hex character in a hex string error message

    Hi everyone,
    I encountered n error message in Illustrator "Acrobat PDF File Format is having difficulties. Non-hex character in a hex string." when trying to open a particular file.
    File was originally created on a Windows 7 PC, tried opening file on Mac OS 10.7.5, same Illustrator version 18. Also tried opening in PDF, Distiller, but didn't help.
    Did tried to change Illustrator Preferences in both Windows and Mac, following the steps in the TecNote:
    http://kb2.adobe.com/cps/500/cpsid_50031.html
    When trying to open the file from the File > Open menu, with the keys held down, it did not open a blank file window, neither did it created a duplicate copy in the Finder where the file is located.
    The file in question had about 15 artboards,  a few embedded images, approx 2.6MB size.
    Any suggestions/assistance would be greatly appreciated.
    Thank you.

    Hi Monika,
    The file was .ai file, as mentioned earlier, was created in Illustrator ver 18.
    Not emailed, stored in the folder, on the Windows PC, not a server. Last saved few days ago, tried to reopen the file from the same computer, but could no longer opened.
    No, Illustrator did not crash, just the error message "Acrobat PDF File Format is having difficulties. Non-hex character in a hex string."

  • Non-hex character in a hex string

    My Illustrator file will not open in Illustrator and I get the "non-hex character in a hex string" window whenever I try to open it. It does open in Acrobat but nothing else. I can't even save it as a pdf file..
    Is there any way I can get around that or fix it?

    karam,
    The first thing to try is to use File>Place in a new document and see how much, if anything, is saved this way.
    The next thing to try is to repair the file code, which is more difficult. The basics are told in this TechNote, the actual recovery consists of changing/adding/deleting code.
    http://kb2.adobe.com/cps/500/cpsid_50031.html

  • Non ASCII String to Hex

    Hi,
    I am writing an algorithm that first encrypts a String, and then converts that String to Hex String. I can successfully parse Hex Strings into Ascii Strings and vice versa, but when I encrypt I cannot do this anymore. Is there a way to convert a non-ascii character to Hexadecimal and vice versa?
    Thanks in advance

    Maybe so....
    The encrypted value when printed does not format on my screen, and appears as boxes and such.
    The values that I am passing in are a very simple encryption....XOR against a key. Here is that algorithm.
    public byte[] encrypt(byte[] value) {
              byte[] encrypted = new byte[value.length];
              byte[] adjustedKey = getKey();
              while (adjustedKey.length < encrypted.length) {
                   String temp = new String(adjustedKey) + new String(key);
                   adjustedKey = temp.getBytes();
              for (int i = 0; i < value.length; i++) {
                   encrypted[i] = (byte)(adjustedKey[i] ^ value);
              return encrypted;          
    Since this is an XOR, I can use the same method to decrypt as well. This is what produces my non-Ascii characters.
    Is there a way for me to get the byte value of a 1 digit hex value then? this may help some.

  • Hex String of format "01:02:03:04:05:06" to Integer?

    Yes, that is a Mac Address,
    does anyone know if there is some "comfortable" conversion routine in Cocoa for converting Hex numbers from String to int?
    The ":" could be stripped, of course, they are only delimiters for easier reading...
    Many thanks for any suggestions!
    Cheers,
    Thomas

    After you strip the colons from the string try something like:
    NSScanner *scan = [NSScanner scannerWithString:hexValue];
    unsigned val;
    [scan scanHexInt:&val];
    'val' will now contain the integer value of the string. 'hexValue' is the hex string. You might need to prepend "0x" to the start of the string too, after removing the colons.

Maybe you are looking for