sjukheter Posted January 29, 2011 Report Share Posted January 29, 2011 (edited) Hi, I want an byte interface that transfers the data serially which makes my USB device not busy. i attched the file that i used for interface but i have doubt about weather it is byte communication or string communication. I am totally new to LABVIEW. how can make byte communication means reading data in bytes and sending data in byte directly but i fell that given VI is receive string and send string. i dont want to convert the string in labview. i want only bte communication. OR i am feeling that VISA will read the dat whatever coming from USB wether it may be byte are any type and then read will produce as string. and the same write that send given string as number of btes. is it right. Thank you. Doc1.doc Edited January 29, 2011 by sjukheter Quote Link to comment
jgcode Posted January 29, 2011 Report Share Posted January 29, 2011 Hi Sjukheter The VISA interface in LabVIEW accepts string data only so you will have to convert the byte information e.g. by typecasting the data etc... Quote Link to comment
sjukheter Posted January 29, 2011 Author Report Share Posted January 29, 2011 Hi Sjukheter The VISA interface in LabVIEW accepts string data only so you will have to convert the byte information e.g. by typecasting the data etc... Then how can i make the byte interface to the coming data. i want to get the data from USB which transfers some 8 bytes of data.. Quote Link to comment
jgcode Posted January 29, 2011 Report Share Posted January 29, 2011 Just convert the data from a string to it's correct representation (whatever format that may be). Quote Link to comment
ShaunR Posted January 29, 2011 Report Share Posted January 29, 2011 (edited) Then how can i make the byte interface to the coming data. i want to get the data from USB which transfers some 8 bytes of data.. The internal representation of a char (1 character of a string) is a byte. If you write the character "A" it s a byte of value 101 (decimal) or 41 (hex). So when you write A to the port you are in fact writing a byte of value $41. A string is an array of characters and therefore an array of bytes. So writing "ABC" you are actually write an array of bytes $41,$42,$43. You can easily convert to and from the representations by using using the "String To Byte Array" and "Byte Array To String" primitives in the string/array/path palette (under the strings palette). But you can only ever write read and write strings using the VISA functions;. Now. When you read (or write) "bytes" that are in the printable character range everything is fine. You will be able to type in values to string controls when writing and when you read it back you will see characters if you usea string indicator However. What if you want to write a hex byte of value 0?. Labview has a very easy way of doing this. If you right click on a string control (or indicator) you will see a menu option for "\" Codes Display and "Hex display. Setting the control/indicator to these will display the "string" in either the escaped format (e.g \00 \00) or in hex byte format (e.g 00 00). so unless you are going to do some function on the values of the bytes (like a CRC) then there is no need to convert and has the added bonus that you can use the string splitting functions to break up the data.. Edited January 29, 2011 by ShaunR Quote Link to comment
sjukheter Posted January 29, 2011 Author Report Share Posted January 29, 2011 (edited) thank you somuch to shanun....you are the god of day... Edited January 29, 2011 by sjukheter Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.