Problem of cast to array of bytes in array of float

Can someone help me find this process I am doing wrong?

  • I read a string of 6 tanks during the series.
  • I take the string and convert it to an array of bytes.
  • I then reverse the byte array because my microcontroller first sends the LSB and Labview is Big-endian
  • I catalogued this table in an array of float
  • I invert the table again to retrieve the data in the original order

I can see the bytes in the array of bytes as 'byte, 0, 0, 0' when there are a small number, but when I I cataloged get very large or very small floats. Can someone help me understand this?

Thank you!

LabVIEW 2011

You should probably use string unflatten, select the byte with rule of the little order and use a DBL 1 d array type. Everything must fall in place without all these gynastics bit, what you're doing.

You can show us your code? I don't understand your use of "decimate the table."

Attach a small VI containingh a typical chain received as a constant of diagram.

Tags: NI Software

Similar Questions

  • BYTE array to float?

    I am relatively new to Labview and haven't found an example of this on these forums.  Any help would be greatly appreciated!

    I read in a stream of characters from a series device, and I would like to convert a 4-byte string (or Byte array) to a float value.  Is there a way to do this in labview?

    For example, I have the table {0x4b, 0x1c, 0 x 90, 0x42} = 0x4b1c9042 = 72.055260 float value

    I can do this in c by:

    Char [] floatarray is {0x4b, 0x1c, 0 x 90, 0x42, 0x00};.

    memcpy (floatarray, & floatvalue sends);

    printf ("float \nMy value is %f", floatvalue);  give 72.055260 for floatvalue

    Is there a way to do this in Labview?

    Note that if you get the chain in that order, you need to invert the first string:

  • Problems with casting light 3D tutorial VCP

    Working in CS5 on this point, but I'm not able to whisk the position of the energy of Orange to light layer 1 layer.  I tried several times now.  I get this message:

    After effects WARNING: object of type found light that requires a number, array, or property

    Expression disabled.

    Error occurred at line 0.

    COMP 'street Footage '.

    Layer: 1 (Orange Energy.mov

    Good: 'Position '.

    Anyone know what they mean by '' number, table or property ''?  There was an earlier instance of pick - whip position layer in this tut and I had no problem.  But this time I'm stuck. I checked the reviews on the site and noticed others had similar problems, but no one seems to have ventured to a solution.

    Any ideas out there?

    Looks like you might be pick - whip to light itself and not the Position property of the light.

    Dan

  • Problem using the pixel format indexed bytes in the PixelWriter setPixels method

    I'm trying to build a byte array and set it on a WritableImage using the PixelWriter setPixels method.

    If I use a RGB pixel format, it works. If I use a byte indexed pixel format, I get a NPE.
    Stride etc should be fine if I'm not mistaken.

    java.lang.NullPointerException
    to com.sun.javafx.image.impl.BaseByteToByteConverter. < init > (BaseByteToByteConverter.java:45)
    to com.sun.javafx.image.impl.General$ ByteToByteGeneralConverter. < init > (General.java:69)
    at com.sun.javafx.image.impl.General.create(General.java:44)
    at com.sun.javafx.image.PixelUtils.getB2BConverter(PixelUtils.java:223)
    to com.sun.prism.Image$ ByteAccess.setPixels (Image.java:770)
    at com.sun.prism.Image.setPixels(Image.java:606)
    to javafx.scene.image.WritableImage$ 2.setPixels(WritableImage.java:199)

    Independent, short example here:
    import java.nio.ByteBuffer;
    
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.image.ImageView;
    import javafx.scene.image.PixelFormat;
    import javafx.scene.image.WritableImage;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Stage;
    
    public class IndexedColorTestApp extends Application {
    
        public static void main(String[] args) {
            launch(args);
        }
    
        @Override
        public void start(Stage primaryStage) {
            BorderPane borderPane = new BorderPane();
            Scene scene = new Scene(borderPane, 600, 1100);
            primaryStage.setScene(scene);
    
            ImageView imageView = new ImageView();
            borderPane.setCenter(imageView);
            primaryStage.show();
    
            int imageWidth = 200;
            int imageHeight = 200;
            WritableImage writableImage = new WritableImage(imageWidth, imageHeight);
    
            // this works
            byte[] rgbBytePixels = new byte[imageWidth * imageHeight * 3];
            PixelFormat<ByteBuffer> byteRgbFormat = PixelFormat.getByteRgbInstance();
            writableImage.getPixelWriter().setPixels(0, 0, imageWidth, imageHeight,
                                                     byteRgbFormat, rgbBytePixels, 0, imageWidth * 3);
            imageView.setImage(writableImage);
    
            // this throws an NPE in setPixels()
            byte[] indexedBytePixels = new byte[imageWidth * imageHeight];
            int[] colorPalette = new int[256];
            PixelFormat<ByteBuffer> byteIndexedFormat = PixelFormat.createByteIndexedInstance(colorPalette);
            writableImage.getPixelWriter().setPixels(0, 0, imageWidth, imageHeight,
                                                     byteIndexedFormat, indexedBytePixels, 0, imageWidth);
            imageView.setImage(writableImage);
        }
    
    }
    If there is no solution, maybe someone knows a solution? We chose to use the format indexed due to the size of the data / performance reasons.

    Published by: Andipa on 01.03.2013 10:52

    You have found a bug in the platform, filed against the project to-online http://javafx-jira.kenai.com to your sample code and a link to this forum question.
    Byte indexed pixel formats seem like a feature never completely (or maybe even any) implemented for me.

    The PixelFormat type uses your unsuccessful case is (PixelFormat.Type.BYTE_INDEXED):

    PixelFormat byteIndexedFormat = PixelFormat.createByteIndexedInstance(colorPalette);
    System.out.println(byteIndexedFormat.getType());
    

    Here are the valid PixelFormat types =>
    http://docs.Oracle.com/JavaFX/2/API/JavaFX/scene/image/PixelFormat.type.html

    BYTE_BGRA
    The pixels are stored in adjacent bytes with the non-premultiplied components stored in order of increasing index: blue, green, red, alpha.
    BYTE_BGRA_PRE
    The pixels are stored in adjacent bytes with the premultiplied components stored in order of increasing index: blue, green, red, alpha.
    BYTE_INDEXED
    The pixel colors are referenced by byte indices stored in the pixel array, with the byte interpreted as an unsigned index into a list of colors provided by the PixelFormat object.
    BYTE_RGB
    The opaque pixels are stored in adjacent bytes with the color components stored in order of increasing index: red, green, blue.
    INT_ARGB
    The pixels are stored in 32-bit integers with the non-premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.
    INT_ARGB_PRE
    The pixels are stored in 32-bit integers with the premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.
    

    As for a WritableImage native pixel format is not the same that you use the pixel format, the JavaFX platform needs to do a conversion while reading pixels in a format and write it in another format. To do this, he must be able to determine a PixelGetter for your PixelFormat (the PixelGetter is an internal thing, API not public).

    And here's the source determines the PixelGetter for a given type of PixelFormat:
    http://Hg.OpenJDK.Java.NET/openjfx/8/master/RT/file/06afa65a1aa3/JavaFX-UI-common/src/com/Sun/JavaFX/image/PixelUtils.Java

    119     public static  PixelGetter getGetter(PixelFormat pf) {
    120         switch (pf.getType()) {
    121             case BYTE_BGRA:
    122                 return (PixelGetter) ByteBgra.getter;
    123             case BYTE_BGRA_PRE:
    124                 return (PixelGetter) ByteBgraPre.getter;
    125             case INT_ARGB:
    126                 return (PixelGetter) IntArgb.getter;
    127             case INT_ARGB_PRE:
    128                 return (PixelGetter) IntArgbPre.getter;
    129             case BYTE_RGB:
    130                 return (PixelGetter) ByteRgb.getter;
    131         }
    132         return null;
    133     }
    

    As you can see, the BYTE_INDEXED format is not supported, and null is returned instead... it is the source of your NullPointerException.

  • Problem with cast/color tone of images in LR catalogs

    About 4 days ago I came across the following problem.  Unfortunately, I don't know of a good way to describe this, so my research in the forum and knowledge base are coming short.  Ideas (or better yet, solutions) would be greatly welcomed.

    The isssue is that any image that I discovered, in any of my LR catalogs, is displayed correctly as all images are only to show the cyan values or orange. (I don't know the right term for this, but it seems that Miami Vice took my camera. Dark tones appear as orange, while lighter ones appear as cyan.)  This occurs regardless of the type of file (jpg, cr2, crw, dng), folder and catalog.  Reset import everything or parameters of development has no impact.  The histogram displays what I see in the previews.  The jpg exported from any image of the catalogue is displayed correctly - no cast.

    Here's what I have:

    LR 3.2 (improved to 3 04/09/10)

    VIsta SP2

    I hope that it is a matter of simple adjustment, something that I have inadvertently changed...

    When I view the DNG existing on my hard drive in another program (Fast Stone Image Viewer), they will be displayed correctly. I tried a variety of other stuff (uninstall 3.2, returning to 2.7, compensation of previews in memory cache, creating of new catalogues, opening the backup catalogs, etc.) without success. So I think that something is wrong in Lightroom only.

    In the screenshot below, you can see the alteration of the color in the flag and pine needles.  Others capture screen shows how images are affected in the same way.

    Slide2.JPGSlide1.JPG

    Thank you kindly, Alyssa

    Looks like your display profile is watered... re-profile of your screen.

  • Problem of two-dimensional array

    I have problems assigning values to two dimension table. Here is an example:

    _Global.test = new Array (new Array, new Array);

    for (n = 1; n < = 3; n ++) {}

    _Global.test [n] ["txt"] = n;

    trace (_Global.test [n] ["txt"]);

    }


    Here is the trace output:
    1
    undefined
    undefined

    Can someone please tell me what I'm doing wrong?

    If you want to create a 2d array, which is an array with two elements, with each element of array, that you use:

  • Problem with 'insert into array.

    First of all, sorry for my English.

    I have a problem with this function, I want to insert an item in the table of size 16 based on the index, but when I insert an element in position 4 (for example) and then I insert another element at position 2, the element that was at position 4 is moved to position 5, and I have no why understan

    Can you help me? Thank you

    Table Insert will increase the size of the table and therefore all which comes after your insert index will be its index increased by the number of items you enter.

    If you want to replace an item in a table - use "replace the subset of the table.

    Here is an example:

    Output:

  • with problems of casting timestamp to date

    Hello

    So here's what I have... I have a timestamp in my database and I need to return it as a date (because what used to work in WL8.1 now gives me a java.lang.IllegalArgumentException: could not convert this to java.sql.Date in WL10). If I change my query as follows:

    I'm not running my old query to get a sample:
    Select col_key, col_time, col_other
    FROM table1 where col_key = "a".

    ... and I get to col_time * January 11, 2013 1:18:04.354261 PM'*... well.

    So, I take this value and I proceed as follows to test my format:

    Select CAST (to_timestamp (January 11, 2013 1:18:04.354261 PM', ' DD/MM/YYYY HH:MI:SS.ff PM') AS DATE) double;
    works perfectly, returns the date: 11/01/2013 13:18:04


    In view of the foregoing I apply to my old query:
    Select col_key, CAST (to_timestamp (col_time, ' MM/DD/YYYY hh:mi:ss.ff PM' ") AS DATE), col_other
    FROM table1 where col_key = "a".

    and I get a "ORA-01858: a non-digit character was found here where was waiting for a digital".

    ... where am I wrong?

    Thank you

    Martel wrote:
    Yes, it's a timestamp column...

    So okay, this is how I read online that I could convert a timestamp into date of...

    Well, what you are trying to convert a string to a timestamp and then convert the timestamp to date. That works, if you pass a string.

    If this is not the case... then how to return a timestamp as a date column?

    I already showed you in my sample code!

    I tried to_date but there is no formatting for milliseconds so why everyone suggests to_timestamp... and if this does not work then what can I do? WL10 convert timestamps java.sql.Date, so I need the request to give him a Date instead of a timestamp.

  • compare arrays of floating point

    Hi all

    I have a table of 2_D as

    1 0,0119

    2 0.0140

    3 0.0157

    up to 50 items.

    and the second picture is as

    0.0137

    0,0153

    0.0156

    up to 20 items.

    I need to compare second table with the second column that is the first table floating-point numbers . Find 20 items in table 1 that are as close as possible (maybe not exactly equal) to the 20 items listed in table 2.

    and return the corresponding values for the colors n ° 1 in table 1.

    ex. - 0.0137 will be compared with the entire table 2.

    He'll find 0.0140 and we get part 2.

    0,0153 next will be compared and so on.

    Final result will be a 1 d array with values of col 1 only.

    Help, please.

    It is confusing that name you the 2D file P1.txt and the 1 d P2.txt file.

    It seems simpler to use "worksheet file read" to read the two files.

    The mistake you make now is to create the table 1 d with the default tab as the delimiter. He reads only one, because there is no tabs in the file. All you need to is change the newline delimiter. It is what it is!

    Now, it seems to work perfectly, please test.

  • Associative array in Oracle procedure problem

    Hello

    I searched through the internet and this forum and have not been able to solve a problem using the associative array of values in an IN clause. Everything I read says that I can not use the associative array directly in the SQL statement. I have to convert it to a table and then I can use it. Unfortunately, I get a ' ORA-21700: object does not exist or is marked for deletion "error when trying to access the table, I filled the table. Please note that I checked the table is actually filled during the loop. I capture the error when you are referencing in the SELECT statement.

    I stated the following in the ARCHIVE package specification:

    TYPE RSType IS REF CURSOR;
    TYPE integer_aat IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
    Integer_table TYPE TABLE IS OF INTEGER;


    The procedure is the following:

    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    RS ON RSType)
    AS
    / * END: Returns the results for the category and key word provided
    VARIABLES:
    v_categories = array of categories of documents
    v_term = keyword entered
    RS = game results
    */
    tbl_cat ARCHIVE.integer_table: = ARCHIVE.integer_table ();

    BEGIN

    BECAUSE me in 1... v_categories. COUNTY
    LOOP
    tbl_cat. EXTEND (1);
    tbl_cat (i): = v_categories (i);
    END LOOP;

    OPEN FOR RS
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    OF TBL_ARCHIVE_DOCUMENTS,.
    B TBL_ARCHIVE_DOC_CAT,
    C TBL_ARCHIVE_DOC_KEYWORDS
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY in (SELECT * FROM TABLE (tbl_cat))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;

    Any help would be greatly appreciated and thanks in advance.

    Matt

    905707 wrote:
    Thanks for the quick response. I looked at the example suggest you and made the following changes. Now, I get an invalid 'Data Type' error on the "column_value SELECT FROM TABLE (CAST (tbl_cat AS tbl_integer))' statement. I must be missing something simple and I can't put my finger on it.

    You did not create a SQL type as I said. tbl_integer is still declared in the PLSQL code you have posted.

    Reread my initial response and look at the example I posted (the very first thing that is done is to create a SQL type).

  • C++ = &gt; LV: array, pointer and memory problem

    Hello

    To research and spent a few days on this...

    I have the following function in C++, which returns a pointer(float *) in an array of float, I need to be dumped in a block of code. I created the DLL and I loaded it in the DLL to LV function (everything is ifne I see and I add the parameters) and accordingly implemented the following example. I then had to find a way to get the pointer to work. All the examples use U32, not a float... There is no float * double or type... back... How is it that is managed?

    So I think I'm sort of on the right track by searching and using the example here:

    http://www.NI.com/example/28672/en/

    I'm sure that isn't true, b/c I simulate the DLL code in MSVS and it works perfectly, but when I have the port, the data are bad... but I get size of 4 floats. ALSO... the memory of DLLS don't reset... so if I run it for the first time, it will calculate the data for n = 0 ==> = 1000 n (see photo), but the next run instead of repeat when I press play, data will begin to n = 1000, ==> n = 2000 all I want to do is pass an array of size 3 type of float data our of my DLL , and in labview... race LV and then stops, the memory will NOT keep its value but reset...

    Here's the function, call others, but you can see:

    char * getYawPitchRoll (float Gx, float Gy, float Gz, float Ax, Ay float, float Az, __int32 msTimeStamp)
    {
    char * YPRptr = YPRDEG; SIZE OF 3 FLOATS DATA TABLE
    getYawPitchRollRad (Gx, Gy, Gz, msTimeStamp, Ax, Ay, Az); written in an array (float) of global variable 'YPRDEG '.
    UpdateYPRDEG();
    Return YPRptr;
    }

    Also attached photo of LV code and library settings *.

    Why is it so ridiculous for LV to manage?

    Please help, I'm out of gas here.

    Thank you

    -Peter

    You must change the table Type, then set the table on pointer data in Table Format. I've never had this problem with variables keeping their previous value and my C is a little rusty, so I'm not sure your problem of Globals. If they are initialized on charge then Taki solution should work, even if repeatedly loading and unloading of the dll should not be necessary. Or maybe you could initialize the when you call your main function? MC

  • Conversion of 3 bytes in an I32

    I have 3 U8 bytes in a table (a byte received 24 bit number). How can I convert them to compliment of 2 number of I32 for general use?

    I wanted to do a .vi I can get value in addition to 2 from content to any position in an array of U8. My problem is that I have a byte stream that feeds coded values that can be 32-bit, 24-bit or 16-bit in size. I wish I could get out somehow the parameter "type" to make it really versatile. Do you know any VI that already do this?

    I may even face values of odd size as 10bits!

    Thank you very much for the solution simplified. I can just go with a code tailored to each type of extraction that I need to do easier.

    I'm starting to see parallels with C. Although I still think that a shift would be useful. As much as the Type cast operator ideally positions the value it reads his entry, at the upper end of the 32-bit value.

    Thanks again.

  • Table 2D SGL typecasting of problem

    Hello

    I'm experimenting with my code and has encountered a problem of cast a 2D SGL table:

    What is the problem here? Type of thread of sources and wells is same "matrix 2D of the single '...

    BTW. It's LV8.6.1.

    One more comment: put a loop FOR all about the issue "catalogued" solves the problem - but the vi should also work without a loop FOR...

    Use "flatten to a string. It works very well. (the value 'prepend... size' false to get the features you want).

    Tables multidimensional cast is a little dangerous, because the reverse does not work. Cast of a string in a 2D array is ambiguous (for example, a chain of 12 elements could be a table 2D 1 x 12, 2 x 6, 3 x 4, 4 x 3, 6 x 2 or 12 x 1). Cast of a 2D array is therefore prohibited, probably because the operation cannot be reversed with an another type conversion and a 2D array as type.

  • Question of casting translates to error #1009...

    Hello

    I'm having a problem of casting I'm hoping to solve. I have 2 tables:

    1 table = parent of the clip that I am trying to target

    2nd table = the clip I'm trying to target

    When I trace the results, I see the clip and the parent of the element, they exist on the stage and are qualified. When I try to get the element by its name in part 3, I get an error #1009.

    Can someone make a preview of what I am doing wrong, or suggest a better way to do what I'm doing?

    Much appreciation,

    ~ Chipleh

    for (var i:Number = 0;i<hitTargetArray.length;i++)
    {
       //1st array
       var hitClipParent:Object = Object(hitTargetParentArray[i]);
       trace("hitClipParent = "+ hitClipParent.name); //hitClipParent = colClip0
       trace(getQualifiedSuperclassName(hitClipParent)) //flash.display::MovieClip
    
       //2nd array
       var hitClip:Object = Object(hitTargetArray[i]);
       trace("hitClip = "+ hitClip.name); //hitClip = hitTarget0
       trace(getQualifiedSuperclassName(hitClip)) //flash.display::MovieClip
    
    
       //Part 3
       var hitTarget:Object = hitClipParent.getChildByName(hitClip);
       trace("hitTarget = "+ hitTarget.name);//TypeError: Error #1009: Cannot access a property or method of a null object reference.
       trace(getQualifiedSuperclassName(hitTarget))
    }
    
    

    in part 3 you must use hitClip.name if you don't see why you do not use Sakurakiss9131 directly:

      var hitTarget:Object = hitClipParent.getChildByName(hitClip.name);

    and now hitTarget is a reference FRO Sakurakiss9131

  • Why visa read reads most bytes sent

    Hello
    I use visa read and write to communicate with the device via RS232. I sent several string commands.i just use serial communication of basic to read and write the commands.my total length of string is about 6626. I also used the size of buffer of about 7000. When I send the string to write Visa, I'll get a number (byte) output 6626 sometimes and sometimes less than that. I also used the property node for the bytes to port I used the number of bytes to read visa. But as number of output here, I get a lot more like over 6670 and sometimes less than 4000and 6620 and sometimes only some and 5000 and some.it doesnot remains constant. How can I solve this problem? why I get more bytes that I sent as exit visa read? and sometimes less? And sometimes more visa write number of output?
    waiting for help.thank you.

    Tadhika,


Maybe you are looking for

  • Worm: 38.4.0 e-mails have two date &amp; time others have only once?

    This has also occurred on the previous 2 versions of the T-BirdThere is no model that I can identify as an email from the same sender will show both ways. I have the column set to Date. I really want the date and time to show all emails.Thank you

  • Should I delete my old firefox 3.6.16 if I install 4.0?

    Should I delete the old browser version (3.6.16) if I downloaded 4.0? The two appear in my list of programs. Running windows 7

  • Re: Satellite A210-MS5 - I need the original BIOS

    Dear colleague, I am very sad to have a failure on the update of the BIOS. Now, unable to start my machine (Satellite A210 MS5). I'm trying to reflash using the method of the crisis recovery disk. I need the original BIOS Version. : 1.00. Anyone have

  • replacement for dv6-3132nr motherboard

    I need a replacement motherboard for my dv6-3132nr, but I do not know where to order a new one. Does anyone have a list of compatible motherboards or a know where I can find a new one.

  • Windows displays a blue screen while playing games

    Original title: Please help me Hi recently I have bouht a compaq persario computer cq42 laptop with windows xp... I'm new to computers when I start a game all of a sudden show of windows a blue error screen saying dumping physical memory and it resta