What is the best way to convert a cluster into byte array or string

I'm writing a program that sends UDP packets and I've defined the data I want to send via large clusters (with u8/u16/u32 numbers, u8/u16/u32 arrays, and nested clusters). Right before sending the data, I need to convert the clusters either into strings or byte arrays. The flatten to string function is almost perfect for this purpose. However, it's appending lengths to arrays and strings which renders this method useless, as far as I can tell. 
As I have many of these clusters, I would rather not hard code the unbundle by names and converting/typecasting to byte arrays or strings for each one. 
Is there a feature or tool I am overlooking? 
Thank you! 

deceased wrote:
Flatten to string has a boolean input of "Prepend string or array size" ... The default value is true.
That only specifies if a string or array size should be prepended if the outermost data element is a string or array. For embedded strings or arrays it has no influence. This is needed for the Unflatten to be able to reconstruct the size of the embedded strings and arrays.
The choice to represent the "Strings" (and Arrays) in the external protocol to LabVIEW strings (and arrays) is actually a pretty bad one unless there is some other element in the cluster that does define the length of the string. An external protocol always needs some means to determine how long the embedded string or array would be in order to decode the subsequent elements that follow correctly.
Possible choices here are therefore:
1) some explicit length in the protocol (usually prepended to the actual string or array)
2) a terminating NULL character for strings, (not very friendly for reliable protocol parsing)
3) A fixed size array or string
For number 1) and 2) you would always need to do some special processing unless the protocol happens to use explicitedly 32 bit integer length indicators directly prepended before the variable sized that.
For number 3) the best representation in LabVIEW is actually a cluster with as many elements inside as the fixed size.
 

Similar Messages

  • What is the best way to get an image as byte array

    Hi, I have an iamge stored in a file (jpg or gif) and I want to get the pixels as byte array. The image will be black and white only (tresholded) so byte will be enough to hold all the colors. What I'm doing now works but it just doesn't look good so I think there must be a better way.
    Thanks!

    just in case somebody else tries to do the same. When
    you first get the jpg image with the JPEG decoder and
    store it in a BufferedImage you can't get the pixel
    samples as byte arrays. You'll have to get them first
    as int[] and then make your own byte[].Anything coming in as pixels tends to be highly organized. You have this image array right. Now, how is it organized you must ask yourself? Then you can access it, bytewise or bitwise!

  • What's the best way to convert a DVD into MPEG-4 format so I can watch on my iPhone 3GS?

    Can anyone help re question?

    since ripping DVDs is not legal
    Ripping commercial DVDs protected via DRM is illegal in many countries (although not all).
    Ripping a DVD you made yourself, of footage you own the copyright to (e.g. your holiday video, wedding video etc) is perfectly legal.
    Handbrake will encode your own unprotected DVDs to MPEG4, but it will not "rip" commercial DVDs.

  • What is the best way of converting a Top Level VI into a 'sub vi' - or function ( without duplicating programming)

    Hi,
    General question here about design architecture, which i keep running into, but haven't found a really good solution.  If i write a 'Top Level VI' to do something, what is the best way of converting it into a subVI - which is call-able from other VIs, while still allowing the top level VI to have synchronised feedback/indicator updates.
    I guess the point is that when something is a top level VI you write gui logic about what happens when someone clicks buttons or whatever - which you don't want in the 'sub vi' version.
    I did at one point try having a hidden boolean button that was an input to the subVI which would let the VI know if it was supposed to be doing the front panel stuff - or simply running as a subVI.  This isn't really ideal though - since it would be better to be able to hive off the grizzly useful stuff from the fluffy - front panel updating stuff - having them together makes the VIs rather untidy.  More annoyingly though, if you have the front panel version of it running - say waiting for you to hit 'go', it breaks all the other VIs that use it as a sub vi - since they can't compile when a sub vi is already running.
    Another possibility that i tried was to basically duplicate the vi so that there was a backend part, and a front end part - and when i click 'go' the backend part is called as a sub vi.  The problem with this is that it really limits the interface that the user gets - since none of the controls on the front panel update with the results untill the sub vi is over.  I guess again i could solve this by passing references to some of the controls to update them in the subvi - but this doesn't really seem like the ideal situation if the subvi is called by something else without the same types of controls etc.
    One final idea i had was to essentially paste all the controls in the VI into a global variable file, and make the sub vi update them, and the front panel VI read from them.  This seems to 'work' - although clearly it is a work around rather than a proper solution - since i spend loads of time worrying about how i update cluster variables in the global - reading and writing.
    Does anyone have any guidance on what they do to solve this problem?
    JP

    You could run a subvis in a Subpanel on your top level.  Lets you see the current data while the subvi is running.
    --Using LV8.2, 8.6, 2009, 2012--

  • What's the best way to convert from Gmail to iCloud?

    I currently use Google's free exchange server and sync my contacts and calendar to Google even though I pretty much do all my emailing from either mac, iphone, or ipad. Since it sounds like it's hard to sync to both google and icloud at the same time, would like to make the switch. Is there a FAQ out there? Can I keep my google email and sync just the contacts w/iCloud or is it an all-or-nothing proposition? If so, is that what others do? Any advice / pointers appreciated. Thanks.

    mike needs help wrote:
    What's the best way to convert Raw images to jpegs?
    GraphicConverter:
    http://www.lemkesoft.com/content/188/graphicconverter.html
    Not free either, but the best shareware program ever made for the Mac.

  • What's the best way to convert a current website into a Fluid Grid Laout?

    As the title says....
    What's the best way to convert a current website into a Fluid Grid Laout?

    See "Using Fluid Grid Layouts (video)"
    http://tv.adobe.com/watch/learn-dreamweaver-cs6/using-fluid-grid-layou ts/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com/

  • What is the best way to convert mini dv tapes to digital

    I have a Canon ZR800 that I have created several mini dv tapes with.  What is the best way to convert these tapes I made to a digital format?  I have a Macbook to use for the digital format.

    Hello Jhoslter,
    To transfer footage from the ZR800 to your Mac, you will need a firewire (IEEE-1394) cable and a firewire port on your computer.  If your computer is not equipped with a firewire port, we would suggest contacting your computer manufacturer for information regarding which firewire card will work best on your system.
    As it is only possible to transfer video to a computer via firewire connection with the Canon camcorder, any video capturing program that supports firewire connections should be fine to use to transfer video to your computer.  Canon does not manufacture video capturing programs or support a particular brand.   
    Canon does not require firewire drivers for any of our miniDV camcorders.  Our camcorders use the driver for your firewire card to communicate with the computer.
    The appearance of the "DV IN" message in the camcorder's LCD screen indicates that the camcorder has detected your firewire port and is waiting for a signal from the video editing software to begin the transfer of footage.  The remainder of the transfer process is controlled by that software; we would suggest reviewing the instructions for that program for further information.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • Aloha, I have a CD-Rom from 2001 that i very much want to access but cannot because i no longer have "classic." There are a variety of video and text files. What is the best way to convert? Any help is greatly appreciated. mahalo.

    Aloha, I have a CD-Rom from 2001 that i very much want to access but cannot because i no longer have "classic." There are a variety of video and text files. What is the best way to convert? Any help is greatly appreciated. mahalo.

    Buy a cheap older Mac like an iMac.
     Cheers, Tom

  • What is the best way to implement a cluster-wide object ID generator?

    What is the best way to implement a cluster-wide object ID generator?

    What is the best way to implement a cluster-wide
    object ID generator?Always use 3 because it is prime.
    Alternatively more information about the system and the needs of the system might prompt alternative ideas some of which are likely to be better than others for your particular implementation and system constraints.

  • What is the easiest way to convert a jpeg into a watermark with CC 2014?

    What is the easiest way to convert a jpeg into a watermark with CC 2014?
    I signed a paper and uploaded the image to the computer as a jpeg to be turned into a watermark.  I'd done it before for a different kind of photography, but have not done it in so long that I cannot remember the steps nor can I find the tutorial video I had watched that taught me how to do it.
    Any help would be greatly appreciated

    Adding to what others have said, if you want to repeat the watermark across the image, it's relatively easy:
    As JJ said, you want to create an image with a transparent background. You can even use his script. Once you've done all that, click Image > Trim with the "transparent pixels" option and leave all the "trim away" options checked.
    Click Edit > Define Pattern to name the pattern.
    Open the image you want to apply the watermark to. Create a new blank layer. (ON EDIT: Select the blank layer.)
    Click Edit > Fill and use the Pattern option under Contents. Choose the pattern you made earlier. Click OK.
    At this point, you can leave it as is or use blending modes and layer opacity to taste. Example:

  • What is the best way to insert massive data into an existing excel file?

    dear gurus,
    i am wondering that what is the best way to insert massive data into an existing excel file, more performance perspective.
    the file is read from BDS , and we want to insert data into it .
    the way i can think of is
    1. OLE AUTOMATION
       i think performance will be a big problem
    2. Office integration
        i am not sure it's facing the same performance issue ?
    3 . XXL_SIMPLE_API/FULL_API
        I am not sure whether they can insert data into an existing excel file?
    could you please give me some advices?
    br.
    jun

    Hi,
    If you want to APPEND data( add data to an existing excel file) from SAP, then use GUI_DOWNLOAD fm with APPEND = 'X' paramter.
    Best regards,
    Prashant

  • What is the best way to turn line art into a 3D image in Illustrator? Thanks for your help.

    What is the best way to turn line art into a 3D image in Illustrator? Thanks for your help.

    What version of Illustrator? What do you mean by "Line Art"? What do you mean by "3d image"? Post images showing your starting artwork and an example of what you are trying to achieve.
    If you have Illustrator 12 or higher you can extrude or lathe a simple group or path using Effects > 3D > [Pick one]. You must start with vector data, not a placed raster image. You are very limited in what you can do, and you cannot model multiple objects within one 3D world. Each object you extrude/revolve/rotate is its own world, with its own perspective and camera. You can also make any art into a Symbol, then map that symbol onto any 3D surface you create. The results are, at best, acceptable, and often total garbage.

  • What is the best way of converting everything in a result set into a string

    hello folks
    What do you think is the best way of converting everything in a resultset into a string???
    At the moment I'm using
    rs.getString(i);
    everywhere (no matter if the underlying datatype is a date or whatever..) it converts automatically evertything expect NULL into a valid string.
    Are there better (simple to use..) ways?

    I don't see a big switch construct. How about trying the following:
    Call this method from your original method by passing the resultset obtained.
    public String[] convert(ResultSet rs) {
         int col = ((ResultSetMetaData) rs.getMetaData()).getColumnCount();
         String[] record = new String[col];
         int i=0;
         while(rs.next()) {
              if(rs.wasNull()) record[i] = new String();
              else record[i] = rs.getString(i);
              i++;
         return record;
    iDriZ

  • What is the best way to put various songs into one album?

    I have been adding album information and album artwork within iTunes to take advantage of cover flow, but i have a lot of songs in my music library that are "stand alone" songs - it is the only song from that artist. I want to put all of these songs together in one album, so all of my miscellaneous rock songs will be put into a Rock Music album or file. I want to do this to eliminate all of the grey boxes within cover flow for all of these songs. When i give the files all the same album name (Rock Music) and album artist (Various Artists) it still does not put them all together within iTunes. It will do it for some, but not all.
    What is the best way to put all of these miscellaneous songs into the same album?

    Try marking all the tracks as part of a compilation. Click on the first track in your list, hold down the shift key and click on the last. Right click anywhere in the selection and choose Get Info, when you are asked if you want to edit multiple items say yes. Change compilation at the bottom of the window to Yes.

  • What is the best way to take a cluster, unbundle it, and output to controls?

    I have a sub-VI with a cluster of controls coming into it. After I get the cluster into the sub-VI what is the best way to unbundle it and apply the values to the controls in the sub-VI? I am trying to stay away from unbundling it and then wiring a local variable of each control to the unbundled name. What other ways are there of performing this type of operation? Thanks in advance for any help.
    Troy

    Hi Troy,
    well you could work with clusters directly. This way there is no need to unbundle and bundle again...
    Otherwise you can work like this to change values in a cluster:
    (Yes I know, the code is quite senseless...)
    Message Edited by GerdW on 07-26-2007 04:21 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    cluster.png ‏2 KB

Maybe you are looking for

  • Changing the size of font in the sidebar

    Do any of your 'mac-gurus' know of a way to increase the size of the font in the side bar? I know one is able to increase the size of the folders, applications, etc but I'd love to find a way to increase the size of the 'home,' 'applications,' 'music

  • New requirement in adding a Company Code...

    Hi All,      There is a new requirement is adding some new Company Codes. Once the company code is segregated and added in ECC. How much effort  required to set up this new company code in BI? Could anyone please guide, what would be the activities p

  • Web Service Request Xml

    Hi, I have an web service deployed. I wanted to write a client which will show me an sample request xml for any particular operation. Is there any way by that we can generate the request xml by querying the WSDL file. Thanks.

  • Export dump

    what is maximum size of export data dump on linux, windows,unix; please reply thanks all

  • Gone through 6 Routers.... why do these routers keep doing this?

    So.... First router i ever bought was WRT54G and i wanted to upgrade to N so recently i picked up a Linksys E2000. and got it home, and worked awesome... ping was low. download speeds were at exactly what im paying for with Suddenlink. 8mbps. and the