Read a Particluar series read byte


I'm relatively new to the use of labview and trying to create an application that reads and writes data in a counter via rs232. I use reading series VISA and VI to write to it. The problem I have is the message that I've read is 6bytes in length. Then, I need to read the second byte at the beginning and go read the other bytes received subsequently. What is the best way to do it? know store buffer and read the individual bytes as necessary.

Also, what is the best way to set up an IF statement in labview.




You can use the string to extract individual bytes of a multibyte string.

Version of LV of the IF statement is a case statement.  See here

Rate it!

Tags: NI Hardware

Similar Questions

  • read byte serial number

    Hi all

    I have a small application that consists of reading data from a serial port using the VISA READ function. The data source that I am trying to acquire the serial port is a microcontroller that sends a word or a byte (8bits). However, when you try to download the programming code in the microcontroller, the programming software backup code in the HEX file into the chip.

    It's all just an explanation into the problem.

    in oreder to get my application actually, I used the attached VI have not program but adds some functions for multiple purposes. The Vi works perfectly and everything works fine, but it seems that I had some misunderstanding here.

    what I'm trying to understand here is why a function (hexadecimal string to number) is used for as much that I have configured everything to read bytes (8bits)

    I am very confused

    any suggestion would be appreciated.

    Thank you

    Converted to 8.5 and attached.

    You can also use

    to perform the conversion.

  • Problem with read (byte [], int int.) in BONE

    Is there a known issue with reading does not correctly in the latest versions of OS 5?

    I have an existing application that works perfectly on all devices 4.2.1 BB + OS... except for devices running the latest versions of OS 5.0.0 when I test on the Simulator for OS (generic), I get strange behaviors using the read() method on the InputStream created from InputConnection.openInputStream () of an HttpConnection.  The problem occurs only when connecting using deviceside = true.  It does not affect MDS.  What I see is:

    read (buffer, index, length) fills a 1024 bytes of the buffer with the http response data internally.

    then, it ignores the first 152 bytes and returns the rest of 872 in the buffer parameter.  The returned value for the number of bytes read int is correct.  that is, 872.

    Subsequent calls to read() to return the same 872 bytes. ... He never advances through the flow to return the rest of the data.

    Method available() at any point returns the length of the http response (in this case, 2685)

    In all previous versions of the operating system, using the same code, it returns all the 2685 bytes in a single call to read()... I'm puzzled.  Also has anyone seen this behavior?

    I had problems similar to the 8830, but with an o/s 4.2 or 4.5

    Finally I changed my read() to read a single byte at a time, rather than a buffer and that solved

    My question.

    If I remember correctly, in my case, I knew the total length and was reading in pieces,

    move my shift in the buffer, the amount of data returned by read(byte[],init,int)

  • Series read byte command change


    I'm new to Labview and I'm reading the speed and torque of a couple of reference via RS232 transducer. I need to read the data as a frame of 6 bytes. I followed the Protocol provided by the manufacturer (3 bytes concatenated + some calculations give couple and 4 and 5th concatenated byte gives the speed and the last byte provides the power supply on the torque sensor).

    When I re - run my code, to change the order of the bytes. In the two screenshots, I have attached the correct order (with 128 in the first byte). But sometimes, when I run the code changes of the order, so instead of 0 1 2 3 4 5 go, it reads 3 4 5 0 1 2 (or else), that ruin my calculations.

    I tried switches ON and OFF the stop character and by changing the flow control settings, but it makes it worse or is not good. Forgive me for my lack of knowledge in Labview or basic serial communication.

    I would appreciate any information about this. Thank you!

    Kind regards



    1 fix the order of byte (expected)

    2 bad byte order

    3. my vi

    The probe is the streaming of data.  This means that it continues to stream without your vi have to ask all the data.  When you read data from the stream, you need to know where is the first byte of the frame.   You must be synchronized with the data structure.  Do you know how many times he transmits a data frame?

    Document you posted says the 7 Bit (MSB) of each byte is used to synchronize the image.  First byte has Bit7 = 1 and the rest of the bytes have bit7 = 0.  This means that the first byte will always be a value equal or greater than 128.  The other bytes will always be 127 or less.

  • Problem: read bytes to serial port

    Hello, I need to communicate with an external device with serial port. I have to write a command to my device string, and then it should play with 64 bytes of data. I built a function of READING-WRITING and I use it in a loop (I have to read a lot of 64-byte block)

    Sometimes, I have the following problem:

    (1) I have send the command string, I wait with "Bytes to the serial port" whereas I have more then 60 bytes, then I read.

    (2) sometimes happen that the read function cannot read all 64 bytes, so the net for cycle, I have in the receiver buffer mor than 64 and the program to stop working. (does not work well)

    I need to be sure that after writing the command I have 64 bytes, so I red all the 64 bytes so the next loop for, I have the buffer of the empty receiver.

    I enclose my writing reading function. Please refer to the block diagram (there are a few notes).

    Thank you

    In no place in your program see the VISA configure the Serial Port. It's always a good idea to include this that even if you use the default settings. I suspect this is one of the default settings which is wrong with you. By default, playback is set to end when a character is considered. This means that if you have a 10 hex (ASCII LF) in your stream, playback stops until the specified number of bytes is read. Put in a VISA set up the Serial Port and connect a constant False to the stop character allow entry.

  • TCP read bytes to read

    Hello! I have a small question on ports TCP read palett in labview, im trying to send 1 bit from a server to a client. This works when I put 4 digital in the bytes to read TCP entry read client-side. But when I change the value to 1, as it should be efficiant, this work dosent. Any ideas?

    Your number of bytes value is a number of I32 (32 bits, or 4 bytes), so you send 4 bytes followed by 1 byte for the boolean itself.   You can convert the number of bytes in an I8 to make a byte (but I wouldn't bother because the IP header information is the number of bytes, which means 1 to 4 bytes means little).

  • Visa read byte at the port

    My visa to read, I feed in the bytes in the property node port as input for the number of bytes to read (it's 4 bytes).  However, the output of the read visa give only 2 bytes.  It seems that a few bytes have been lost during the read operation?  Why is this?  It is an easy to see what is in the buffer of the serial port?  Thank you!


    You likely the session VISA set to end readings when he sees a stop character and VISA reading is to see the stop character, and ending the reading, regardless of the number of bytes you told to read. If you want that it explicitly read that much then you must disable the option "Activate the stop character" in VISA set up a Serial Port.

  • Read bytes to lan


    I would like to read the number of bytes sent and received on a specific lan connection? I would like to create a simple network monitor.
    but I found nothing.
    Can you help me?
    I tried to analyze the netstat-e but bytes are not specific to a connection, and totally bytes do not match connection status windows.

    Joint connection status windows and netstat

    If you are a windows user, you can use this.

  • Read byte with a value up to 127 lire byte with an ASCII value greater than 7F (127 dec)


    I have to read a byte with a value greater than 127, Labview turn 27.

    In help I saw that Labview provides a description of ASCII that pour values ranging up to ' 127.

    What do I need to do?

    LabVIEW 6.1

    Windows XP


    I want to read a byte with a maximum value of 127, but Labiew reurn arround 27 value

    How do I do?

    Rigid wrote:

    Thanks for your help. I'm not changing lyke I understand (my English is poor quiet...)

    I have another program that communicate with the instrument. I know byte (6) must be greater than 18 (greater than 7F actually).

    But with Labview, I'm only 18.

    While it might be higher than 18 x, an I8 is signed, and therefore it cannot be greater than x7F - it has a range of-128 to 127. A U8 is not signed, and it's why he has a range from 0 to xFF. However, x 18 is the same if you treat as signed or not signed. I don't see how LabVIEW can read a wrong value on the serial port. Are you sure you're looking at the correct byte? Your code shows that you split the chain twice. Are you sure that you do this properly?

    Given that you use on Windows you can recheck the chain received using PortMon. Allows you to see what is actually received by the driver for the serial port on Windows.

    P.S. I actually meant the whole byte function.

  • Binary file read byte unmatch

    I tried to read a line from the binary as the top of the screenshot.

    The result is that the left side. It shows the first part with the text are correct. The final part is not match with that gross.

    I also tried read by byte, but still the same.

    Any suggestion, thank you.

    I couldn't find a sequence of 3 30 2 31 30 30 00 04 3F... any where in the two files contained in the zip file that was in the other thread. I think you open a different file with LabVIEW.

    Have you tried the converter program that David mentioned in your original thread?

  • Question about the RAF read byte array, method


    I use file access random byte array read method to read a file. I will print each line, when printing to the last line, it is added with some null characters.

    Can you please suggest how to remove null characters in the last line?

    I use file access random byte array read method to read a file. I will print each line, when printing to the last line, it is added with some null characters.

    No, you're ignoring the read count returned by the method and the treatment of the whole buffer.

  • Read byte/char from socket inputstream

    Hey fellow coders.
    I ran into a bit of coding of a http client drive problem for my assignment. I created a simple program that opens a connection with a server and the request for a file to download. The socket inputstream is encapsulated in a bufferedreader and I can successfully retrieve the response of the full text of the server via the player. Unfortunately, every time I download an mp3 file, the data is corrupted. The problem lies in the fact that bufferedreader decodes the stream of bytes into a string with the utf8. I can't use the underlying socket inputstream as bufferedreader has already read before in and perhaps spent the beginning of the content area. Analysis of the chain with getBytes ("UTF 8") does not work that the audio file is damaged.
    My question is, is there any player that can send me data from a stream unique both as char or byte? Everyone fell on this problem and found a solution for it?

    Thank you.

    The socket inputstream is encapsulated in a bufferedreader


    and I can successfully retrieve the response of the full text of the server via the player.

    Why is the server sends a response text followed by binary data?

    In this circumstance, I would use DataInputStream.readLine (), despite his disapproval, followed to call read() to get binary bytes.

  • How to stop the series 'VISA read' the sends packets instead of bytes available.

    Dear Labvillians,


    How can I stop series "VISA read" send me packages rather bytes?


    I have a system which publishes series of 14 bytes on a semi-regular interval packets.

    At busy times, the producer of these these queues of data packets, effectively producing Super-paquets multiple of 14 times larger than 8 packages (112 bytes) bytes.

    My protocol handler is designed to process bytes, packets, or packets Super.

    Now, my request has multiple devices and the order of message processing is essential to the proper functioning.

    My observation is that read VISA waits until the end of a package / super package before moving the data to the application code. (See chart below)

    My expectation is that VISA read should give me bytes available, get too smart for itself and not wait for a package.


    I noticed this on PXI, PC shipped, PSC and, more recently, cRIO

    I've experimented with Scan interface the cRIO rate, which helps to reduce the backlog of packages but don't decide to package under read byte.

    I understand that a solution is FPGA code write to handle and pass the bytes by R/T-FIFO, and there are some great examples on this site.

    Unfortunately, it does not help with FPGA devices not.

    I have also dabbled in the event based sequential reads, but he is evil on vxWorks devices.

    Any help is appreciated

    It is helpful to sometimes talk to yourself.

    I hope that is useful for someone sprinkle in the future

  • problem with the bytes to port to read in VISA

    Hi guys,.

    I'm reading device data using usb - BT dongle. It creates the virtual port and read without problem.

    My problem is the packages to send 428 bytes, inside this block device, I have 400 bytes of data bytes 9 to 409. The first 3 bytes of each block is the same.

    4 45 50 - MEP, they are the first 3 bytes of each block of 428 bytes.

    Okay, if you check the vi I config the visa and sending the data of adjustment of the device, read the answer and it sends the data to start sendding data.

    Well, I try to read each block of 428 and show in a chart.

    The problem is sometimes bytes in ports are 428 and anothers shows 23, 2, 125,... is not continuous 428 bytes each iteration and destroy the data graphic.

    IF I check the chart outside of the main loop, I see the correct graph. Apart from mainvi I collect whole data and separate in 428 blocks, extract the 400 bytes of data and analyze the entire signed 16 bit and display in the graphics.

    So, I don't know the best way to get 428 bytes in each iteration... I tried to read directly the 428 bytes but sometimes fail once again, very low reading bytes... take time to wait before read bytes to each iteration. I need a way to get 428 before values to get the readings of 400 data. Even I could probe each beginning of block with 4 D 4550 HEX bytes to pass and got data...

    Perhaps it would be better to use the wait? or using a while loop to wait until I had 428 bytes? Any help will be apprecite.

    Best regards, Fred.

    You receive binary data.  Therefore, turn off the the stop character.

    What happens is that you actually 0x0D in your data.  Playback VISA who sees and then request's made it reading the data.  By turning it off, then reading VISA will read all 428 bytes or until a time-out occurs.

    Let the constant instead of the bytes to the Port.

  • How to read 200 bytes of a file albums

    I have to read bytes n top of page of a set of very large files in the system in my WebWorks app, but I do not know how to implement it. Please help me.

    Thank you

    Hi huydq5000,

    Using the FileReader, you can use the function called readAsBinaryString (blob)

    Suppose you had a file named file object and a FileReader object named reader.

    You can use file.slice (startByte, endByte) to get a piece of your object file Blob, in your case it would be something like:

    reader.readAsBinaryString (file.slice (0, n));

    Take a look at the section 'Cut a file' in this link:

Maybe you are looking for