JNI Array problem

Hello sir,
here i got problem while calling java method having array as arguments from c++;
here is java code which is called from c++
class PQR {
     public void xyz(int[] ia) {
     System.out.println("hi");
          for (int i = 0; i < ia.length; i++)
               System.out.println(ia);
c++ call code snippet =>      invoke.invoke_class("PQR", "xyz","([I)V");{code}
here when i call this xyz method i just get o/p as => hi
means all jvm related calls are working even method xyz gets called but i am not able to acces to array .
can anybody tell me how to get access to those array elements?
Edited by: Amit_pune on Mar 1, 2008 2:19 AM

The code looks rather strange. Casting a pointer to a pointer to a short (&bufferbody) to be a pointer to an int.
Maybe you could post the code of modify.
Also, and as an aside, if I'm reading the code right, you have a potential memory leak because you're using JNI_COMMIT rather than just 0.
Sylvia

Similar Messages

  • A quick Array Problem

    hey all,
    i'm having a dumb array problem, I cannot figure out what I've done wrong !
    I've set up an empty array of JButtons (because that '4' is actually a variable in my code)
    HERE IS THE CODE
    //===========================
    JButton[] buttons = new JButton[4] ;
    for (int g = 0; g < 4; g++)
    Imag[g].setIcon(imageIcons[g]);     
    buttons[g].setEnabled(true);
    System.out.print (buttons[g] + " " + g + "\n");
    //===========================
    My Error is a null pointer exception. And when I take out the:
    buttons[g].setEnabled(true);
    line, I just get the ouput, and it is:
    null 0
    null 1
    null 2
    null 3
    Ok, I know I'm probably making one dumb little mistake, but I have no idea what it is right now, Please Help !! thanks,
    Kngus

    When you want to use an array, you declare it (which you did), construct it (which you did), and initialize it (which the VM did). When you initialize an array of primitives, the primitives get their default value (0 for signed int types, 0.0 for float types, false for boolean, null-character for char) and so do object references (null).
    You are setting up an array of object references. When the VM initializes it, the elements of the array (i.e. the references to the JButtons) are set to null. That's why you're getting the NullPointerException. You need additional code, something along the lines of this:
    for(int j = 0; j < buttons.length(); j++) {
        buttons[j] = new JButton();
    }Now, your buttons array will contain references to JButtons rather than null.
    AG

  • Transposin​g Array Problem

    I need to get the information from a table which has been populated at an earlier point in the program, and convert it to numbers, and then break it up into its individual elements. Both ways of doing this in my attached vi work, but the one method throws three 0's in between columns, when I resize the 2D array to 1D. Any idea why? Is there an easier way to go about this?
    Thanks, Geoff
    Attachments:
    Array Problem.vi ‏26 KB

    Your original table contains 3 extra row which generate 3 rows of zeroes. Your 2D array actually contains 35 elements. the reshape function truncates to 20 elements. After transposing, you throw away nonzero elements while before rehshaping all zeroes are in the tail giving the false apperance of correct behavior.
    The attached modification gives you a button to fix the table size so it works correctly.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ArrayProblemMOD.vi ‏41 KB

  • Error: Non-array passed to JNI array operations

    Can anyone see what I am doing wrong? I am trying to go through the array of objects example in the online JNI text book "The Java Native Interface Programmer's Guide and Specification" by Sheng Liang. The book and pertinent chapter can be found here:
    http://java.sun.com/docs/books/jni/html/objtypes.html#27791
    The error I received on running the program with the -Xcheck:jni switch is this:
    FATAL ERROR in native method: Non-array passed to JNI array operations
         at petes.JNI.ObjectArrayTest.initInt2DArray(Native Method)
         at petes.JNI.ObjectArrayTest.main(ObjectArrayTest.java:14)Without the xcheck switch, I get a huge error log file that I can reproduce here if needed.
    My c code with #ifdef _Debug statements removed for readability is listed below.  The location of the error (I believe) is marked:
    #include <jni.h>
    #include <stdio.h>
    #include "petes_JNI_ObjectArrayTest.h"
    //#define _Debug
    // error found running the program with the -Xcheck:jni switch
    //page 38 and 39 of The Java Native Interface Guide by Sheng Liang
    JNIEXPORT jobjectArray JNICALL Java_petes_JNI_ObjectArrayTest_initInt2DArray
      (JNIEnv *env, jclass class, jint size)
         jobjectArray result;
         jint i;
         jclass intArrCls = (*env)->FindClass(env, "[I");
         if (intArrCls == NULL)
              return NULL;
         result = (*env)->NewObjectArray(env, size, intArrCls, NULL);
         if (result = NULL)
              return NULL; 
         for (i = 0; i < size; i++)
              jint tmp[256]; // make sure it is large enough
              jint j;
              jintArray iarr = (*env)->NewIntArray(env, size);
              if (iarr == NULL)
                   return NULL; 
              for (j = 0; j < size; j++)
                   tmp[j] = i + j;
              (*env)->SetIntArrayRegion(env, iarr, 0, size, tmp);
              (*env)->SetObjectArrayElement(env, result, i, iarr); // ***** ERROR:  Non-array passed to JNI array operations
              (*env)->DeleteLocalRef(env, iarr);
         return result;
    }Here is my java code
    package petes.JNI;
    public class ObjectArrayTest
        private static native int[][] initInt2DArray(int size);
        static
            System.loadLibrary("petes_JNI_ObjectArrayTest");
        public static void main(String[] args)
            int[][] i2arr = initInt2DArray(3);
            if (i2arr != null)
                for (int i = 0; i < i2arr.length; i++)
                    for (int j = 0; j < i2arr[0].length; j++)
                        System.out.println(" " + i2arr[i][j]);
                    System.out.println();
            else
                System.out.println("i2arr is null");
    }Thanks in advance!
    Pete

    Niceguy1: Thanks for the quick reply!
    So far, I mainly see the usual differences between C and C++ JNI calls. Also, in the example you gave, they use a lot of casts, but that doesn't seem to make much difference to my output. Also, in the example, they create a 0-initilized int array, and use this class to initialze the class type of the Object array. I get the class type by a call to FindClass for a class type of "[I".  I'll try this their way and see what happens...
    Edit:  Changing the way I find the array element Object type did not help.  I still get the same error as previous.  Any other ideas would be greatly appreciated.
    Message was edited by:
            petes1234                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • FATAL ERROR in native method: Non-array passed to JNI array operations

    After stepping up to JDK 1.4.2 we started getting a hotspot error, I added -Xcheck:jni and it yielded the above error which was not existent in JDK 1.4.1 and for the life of me I cannot find out whats wrong:
    Native method dec:
    private native byte[] cost(final byte[] byte_array,
    final double minCostPerMeter,
    final int costFuncSelection,
    final double maxCostThreshold);
    Method call:
    ByteArrayInputStream
    inputByteStream = new ByteArrayInputStream(
    cost(output_byte_stream.toByteArray(),
    minCostPerMeter,
    costFunctionSelection.length,
    maxCostThreshold));
    An array is being passed I have no idea why it is complaing about the method call.
    Any help would be appreciated.
    -R

    What happens if you remove all the code from the JNI method - so it just calls and then returns?
    If it still occurs then I would expect that you have a memory problem in a piece of code before this one. Such problems can have no impact when run in one environment but cause failures in another becomes some other legitimate piece of data moved.
    If it doesn't then I would expect that the problem is in the method itself and not the call.
    It could be some odd VM problem so trying a different version of 1.4.2 might help (but in of itself would not eliminate the possibility that you have a memory problem.)

  • Freshmen for JNI several problem  urgently

    hi,
    1.. I have created the Cpp file to implemement the native method but it seems that the native method can not complie rightly , it tells me follows
    error C2819: type 'JNIEnv_' does not have an overloaded member 'operator ->'
    c:\program files\microsoft visual studio\vc98\include\jni.h(764) : see declaration of 'JNIEnv_'
    c:\users\wangyue\desktop\java_gui\beattrack 5.6 - ������_������_������������ 5.7\beattrack.cpp(202) : error C2227: left of '->GetByteArrayRegion' must point to class/struct/union
    then I use the c file to paste the same code, it can complie rightly , why? I really need my native method to complie rightly in Cpp file, how to solve it?
    2.I want to return a double, for the most simple way, I do the following
    #include "RealBeatTrack_BeatTrack.h"
    JNIEXPORT jdoubleArray JNICALL Java_playaudio_BeatTrack_BeatTrack
    (JNIEnv *env, jobject j, jbyteArray data)
         jdouble outdata[4]={1,2,3,4};
         return (*env)->NewDoubleArray(env, outdata);
    then in the java code, I difine a array to receive it,
    say double mydata[] = new double[4];
    mydata= BeatTrack(buffedata);
    but the java comlier tells me the Exception in thread "Thread-2" java.lang.OutOfMemoryError: Java heap space?
    anyone can help me?
    Thanks

    at least question 1 has been answered [ by AmitGee in this thread|http://forum.java.sun.com/thread.jspa?threadID=5302982&tstart=3]
    and question 2 is now obsolete, though I still have a new problem which I will post in a separate thread.
    Thomas

  • MS Office Report Express VI and Array Problem

    Hello all,
    I have a strange issue with the MS Office Report VI that's included with the Report Generation Toolkit. I created an Excel template which I linked using the "Custom template for Excel" preference and applied all the named ranges. However, two of the named ranges that I am inputting are 1D Arrays of doubles. Now the problem:
    When I input the arrays to their specific name range (it's only 6 values), instead of inputting just the array values into the cells, it inputs like this:
    0    Value
    1    Value
    2    Value
    6    Value
    It pushes the "Value" to the column next to the name range because of the 0-6.
    It does this with both arrays so it screws up all the formulas. Any one know how to remove the 0-6 and just input the values?
    Thanks all 
    Solved!
    Go to Solution.

    Greetings, I wrote a program that generates an array of data and stores a data table, just as a chart, just starting to program, I hope that my program can be useful
    Atom
    Certified LabVIEW Associate Developer
    Attachments:
    write_excel.vi ‏60 KB

  • Assigning value to a two-dimensional byte array - problem or not?

    I am facing a really strange issue.
    I have a 2D byte array of 10 rows and a byte array of some audio bytes:
    byte[][] buf = new byte[10][];
    byte[] a = ~ some bytes read from an audio streamWhen I assign like this:
    for (int i=0; i<10; i++) {
        a = ~read some audio bytes // this method properly returns a byte[]
        buf[i] = a;
    }the assignment is not working!!!
    If I use this:
    for (int i=0; i<10; i++) {
        a = ~read some audio bytes
        for (int j=0; j<a.length; j++) {
            buf[i][j] = a[j];
    }or this:
    for (int i=0; i<10; i++) {
        System.arraycopy(a, 0, buf, 0, a.length);
    }everything works fine, which is really odd!!
    I use this type of value assignment for the first time in byte arrays.
    However, I never had the same problem with integers, where the problem does not appear:int[] a = new int[] {1, 2, 3, 4, 5};
    int[][] b = new int[3][5];
    for (int i=0; i<3; i++) {
    b[i] = a;
    // This works fineAnybody has a clue about what's happening?
    Is it a Java issue or a programmers mistake?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Back again! I'm trying to track down the problem.
    Here is most of my actual code to get a better idea.
    private void test() {
         byte[][] buf1 = new byte[11][];
         byte[][] buf2 = new byte[11][];
         AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(audioFile);
         byte[] audioBytes = new byte[100];
         int serialNumber = 0;
         while (audioInputStream.read(audioBytes) != -1) {
              if (serialNumber == 10) {
                   serialNumber = 0; // breakpoint here for debugging
              // Fill buf1 -- working
              for (int i=0; i<audioBytes.length; i++) {
                   buf1[serialNumber] = audioBytes[i];
              // Fill buf2 -- not working
              buf2[serialNumber] = new byte[audioBytes.length];
              buf2[serialNumber] = audioBytes;
              serialNumber++;
    }I debugged the program, using a debug point after taking 10 "groups" of byte arrays (audioBytes) from the audio file.
    The result (as also indicated later by the audio output) is this:
    At the debug point the values of buf1's elements change in every loop, while buf2's remain unchanged, always having the initial value of audioBytes!
    It's really strange and annoying. These are the debugging results for the  [first|http://eevoskos.googlepages.com/loop1.jpg] ,  [second|http://eevoskos.googlepages.com/loop2.jpg]  and  [third|http://eevoskos.googlepages.com/loop3.jpg]  loop.
    I really can't see any mistake in the code.
    Could it be a Netbeans 6.1 bug or something?
    The problem appears both with jdk 5 or 6.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • RAID 5 array problem

    Hi,
    I've a problem arising from the replacement of a drive in a Proliant ML370 G3 RAID 5 array.
    What happened is one disc in the array failed. I replaced it and selected the "F1" rebuild option. The system then appeared to start the rebuild, both the green arrow and the green HD icon on the replaced disc flashing. However, when I returned to the server, over a week later, I found that the HD light had gone out but the green arrow continued to flash on occasion. I had expected the HD icon to remain illuminated and the arrow to flash every so often. When I checked in Disc Manager (Windows 2003 Server) this reported that although both partitions allocated to the array were healthy, there was no fault tolerance. I have since rebooted the server which then responded that the same disc had failed and presented me with a rebuild option.
    I've now tried to rebuild this array three times without success, the result being the same each time I try. What am I missing?
    I'd appreciate any suggestions
    Phil

    You gave a very nicely detailed list of datum ... thanks, that's rare!
    Now ... one other bit ... you mention media being on the Thunderbolt RAID5 ... is everything there, including cache/database/previews/project-file, or just the media? I know that if say everything else was on the system drive, this would probably happen ... the media is the 'easiest' part of the disc-in/out chain as it's mostly "simple" reading of files, those other things are heavy read/write items. I'm assuming you've probably put most of it on that RAID, as the folks on the Tweaker's Page would oft posit.
    Neil

  • Associative Array problem in Oracle Procedure

    Hi,
    I've searched through the internet and this forum and haven't been able to resolve a problem using associative array values within an IN clause. Everything I've read states that I can't 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'm receiving an "ORA-21700: object does not exist or is marked for delete" error when trying to access the table I've populated from the array. Please note that I have verified the table is actually being populated during the loop. I'm catching the error when referencing it in the SELECT statement.
    I've declared the following in the ARCHIVE package specification:
    TYPE RSType IS REF CURSOR;
    TYPE integer_aat IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
    TYPE integer_table IS TABLE OF INTEGER;
    The procedure is as follows:
    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    rs OUT RSType)
    AS
    /* PURPOSE: Return Search Results for the Category and Keyword Provided
    VARIABLES:
    v_categories = Document Categories array
    v_term = Keyword entered
    rs = Result Set
    tbl_cat ARCHIVE.integer_table := ARCHIVE.integer_table();
    BEGIN
    FOR i IN 1 .. v_categories.COUNT
    LOOP
    tbl_cat.EXTEND(1);
    tbl_cat(i) := v_categories(i);
    END LOOP;
    OPEN rs FOR
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    FROM TBL_ARCHIVE_DOCUMENTS A,
    TBL_ARCHIVE_DOC_CAT B,
    TBL_ARCHIVE_DOC_KEYWORDS C
    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

    Thank you for the quick response. I looked at the example you suggested and made the following changes. Now I'm receiving an "Invalid datatype" error on the "SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer))" statement. I must be missing something simple and I just can't put my finger on it.
    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    rs OUT RSType)
    AS
    /* PURPOSE: Return Search Results for the Category and Keyword Provided
    VARIABLES:
    v_categories = Document Categories array entered
    v_term = Keyword entered
    rs = Result Set
    TYPE tbl_integer IS TABLE OF INTEGER;
    tbl_cat tbl_integer;
    BEGIN
    FOR i IN 1 .. v_categories.COUNT
    LOOP
    tbl_cat.EXTEND(1);
    tbl_cat(i) := v_categories(i);
    END LOOP;
    OPEN rs FOR
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    FROM TBL_ARCHIVE_DOCUMENTS A,
    TBL_ARCHIVE_DOC_CAT B,
    TBL_ARCHIVE_DOC_KEYWORDS C
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY IN (SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer)))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;

  • Converting bytes to character array problem

    I am trying to convert a byte array into a character array, however no matter which Character Set i choose i am always getting the '?' character for some of the bytes which means that it was unable to convert the byte to a character.
    What i want is very simple. i.e. map the byte array to its Extended ASCII format which actually is no change in the bit represtation of the actual byte. But i cannot seem to do this in java.
    Does anyone have any idea how to get around this problem?

    Thanks for responding.
    I have however arrived at a solution. A little un-elegant but it seems to do the job.
    I am converting each byte into char manually by this algorithm:
              for (int i=0;i<compressedDataLength;i++)
                   if (((int) output)<0)
                        k=(127-((int) output[i]));
                        outputChr[i]=((char) k);
                   else
                        k=((int) output[i]);
                        outputChr[i]=((char) k);
                   System.out.println(k);
    where output is the byte array and outputChr is the character array

  • Array problem (empty).

    Hi everybody,
    I'm using Crystal X and I have the following query
    IdField          Field1             Field2
    1                  CCC                8
    1                  GGG               3
    1                  DDD                2
    2                  AAA                7
    I want the following output
    IdField
    1               CCC GGG DDD    Field2 define different format to Field1 (different background color)
    2               AAA
    My report is grouped by IdField. As the output for Field1 has a different format depending on Field2. I want to write the Field1+Field2 values for each IdField in an Array, I have the following formulas, but the array looks empty, I have changed the array declaration as global and still is empty
    Section: ReportHeader
    Formula InitArray
                 shared stringvar Array DataArray;
                 redim DataArray[30];
    Section: Details (Suppresed)
    Formula AddDataToArray
                shared numbervar iCounter;
                shared stringvar Array DataArray;
                iCounter := iCounter + 1;
                DataArray[iCounter] := {Command.Field1} + "-" +  {Command.Field2};                                             
    Section: Footer Group1a
    Formulla FillTextFromArray
                shared numbervar sDataVal;
                shared stringvar Array DataArray;
                sDataVal := DataArray[1];  //DataArray[1] shoud be = "CCC-8"
                left(sDataVal, len(sDataVal)-2);
                {@DisplayData1}= DataArray[1]; //This is my problem the array is empty
    Section: Footer Group1b
    Display the following data
    IdField     @DisplayData1  @DisplayData2  @DisplayData3 ...
    I added 50 formulas to display each Field1 value with different formats. I know these columns are fixed, but I coudn't find any other way.
    I have 3 question:
    ??? What is wrong on my array than in formula "FillTextFromArray" is empty???
    ??? Is there another way to refence a formula or a text object different than FormulaName or TextObjectName???, like an object array or something, because I will be dealing with 50 formulas to write the value and to change the format
    ??? How to make reference to a text object, in case I would change the 50 formulas by 50 text objects
    Please help with any of the 3 questions or any ideas to make the report
    thanks
    cc

    You can try another way like
    create anew formula @Initialize
    whileprintingrecords;
    stringvar str:="";
    Now place this in group header of IDField
    Now Create another formula @Evaluate
    whileprintingrecords;
    stringvar str;
    str:=str" ";
    Place this in detail section
    Create another formula like @Display
    whileprintingrecords;
    stringvar str;
    place this in group footer of IDFIeld and right click on this formula and go to format field and check the option "can grow".
    Now you can suppress the sections group header and details section to show the values in a single line in each group footer.
    Hope this helps!
    Raghavendra

  • JNI & thread problem

    Folks,
    I am using JNI to access WIA (Windows Image Acquisition) functionality under MS Windows XP. WIA consists of a bunch of COM interfaces. I have several native functions in a single dll, with a limited number of static variables stored in the dll between calls. This all works fine as long as long as the calls occur from the same java thread, but not if a new thread is created for some of the calls. I.e., this works:
    final WIACtrl ctrler=new WIACtrl();
    ctrler.initializeWIA();
    ctrler.transferJPGNative("0001\\Root\\IMG_0087","c:\\test.jpg");
    but this does not:
    final WIACtrl ctrler=new WIACtrl();
    ctrler.initializeWIA();
    (new Thread() {
    public void run() {               
    ctrler.transferJPGNative("0001\\Root\\IMG_0087","c:\\test.jpg");
    }).start();
    Here, initializeWIA() and transferJPGNative() are the native methods. What happens in the second case is that transferJPGNative fails in one of the COM methods (not the first COM method it calls). The COM method returns an HRESULT indicating an error (509) which I can't find using any of the usual MS error look-up mechanisms. (Admittedly I am not the world's greatest Windows programmer...)
    Anyway, any suggestions would be much appreciated. I have found some issues regarding JNI and threads in this forum's archives, but none of them seem to apply to quite this situation.

    As a guess this is just a windows threading problem.
    And with COM you have to do things differently (I believe) if there is more than one thread. You might not even be allowed to do it with for that particular API.
    It could also be that you are initializing things more than once. Or you need to initialize twice (two handles.)
    At any rate you could always fix it by making the java code only allow calls for a single thread.

  • Mathscript Array -problem

    Dear Friends,
    I am reading the serial port data data , byte by byte..I used serial port vi and math-script in it ....
    And these  serial data are sent in a format like below........
    format:  HEADER ,  MSB  , DATA ,  CHECKSUM..
    I need to collect these bytes and plot it on the graph.. I have problem with saving these data in an array and processing it....
    below is the code,which i had written to do the process
     persistent  ubIndex = 0
     persistent  bHeader = 0
    ubTemp=input
     if bHeader ==0
                     if ubTemp == 89
                            ubIndex= 0
                            bHeader = 1                              
                       end
    else
                  ubIndex= ubIndex +1
                  ubReceivedata(ubIndex) = ubTemp      
                   if  ubIndex == 3
                           ubIndex = 0
                           bHeader = 0               
                     end
    end      
     ubChecksum = ubRecieveData(1) + ubRecieveData(2) + ubRecieveData(3)
    if   ubChecksum == 0
                   if ubRecieveData(1) == 76
                            duLen1 = ubRecieveData(2)
                                 elseif   ubRecieveData(1) == 69
                                        duLen2 = ubRecieveData(2)
                                 elseif   ubRecieveData(1) == 78
                                           duLen3 = ubRecieveData(2)
                                   elseif ubRecieveData(1) == 71
                                                duLen4 = ubRecieveData(2)
                                                duLength = duLen1 * 16777216 + duLen2 * 65536 + uwLen3 * 256 +  ubLen4 
                                  elseif   ubRecieveData(1) == 80
                                               uwTemp1 = ubRecieveData(2);
                                   elseif  ubRecieveData(1) == 66
                                                ubTemp2 = ubRecieveData(2);                 
                                                uwpackageSpeed = uwTemp1 * 256 + ubTemp2;
                                     elseif  ubRecieveData(1) == 68
                                              uwTemp1 = ubRecieveData(2);
                                     else  ubRecieveData(1) == 65
                                              ubTemp2 = ubRecieveData(2);                 
                                             uwDrumSpeed = uwTemp1 * 256 + ubTemp2;
                       end
    end
    In the above program,i collected 2nd, 3rd,4th byte in the ubRecieveData array  and i left the 1st byte(which is header)...
    and I find the checksum by adding the 2nd,3rd,4th byte to find whether it is zero or not,
    if it is zero ,then the received bytes are correct...and it will proceed to take only the data bytes...and i will plot it on the chart...
    I have a doubt in the ubrecievedata array..whether it is collecting the 3 bytes data or not......whether array  get's initliazed every time in the script..
    since it doesn't get in to the if-loop checksum and loop further.....
    I even removed the if-loop checksum ,to collect and process the data inside the loop below if-loop checksum..but it's not working ...
    will the above script are correct..... .....?suggest some solutions to get working
    i attached my  program vi..for u to get feel of my problem...
    regards
    rajasekar
    Attachments:
    vjnewsamp.vi ‏319 KB

    Hi Grant,
    I did as u told u,still unable to process the data and plot it on the chart.....
    I attached my program  testing20.vi ....for finding the problem..
    could u please see the vi..and suggest some solutions....
    As u said  the array should also be persistent.....and my doubt is the other variable like dulen1,dulen2,dulen3,dulen4,...should also be persistent...in order to calculate the parameter
    duLength,.......similarly the parameter uwpackagespeed and uwdrumspeed should be persistent.(in my point of view....)
    objective of the program is to read the serial port byte and byte ...and plotting it
    And the byte are sent in format like
    format: Header , MSB ,data,checksum..
                 Header, LSB ,data,checksum..
    so i need to recogize this format in my mathscript node ...the main thing is ,...... in 4 bytes the data is only of 1byte....
    In my program , i am plotting length(x-axis) versus packagespeed and drumspeed(y-axis)..
    here the length parameter itself 4 byte of data.....i have to collect it byte by byte of data ,...from the 4 byte format(math script gets called 16 times to collect these 4 data bytes
     from 4 byte format)...        and packagespeed and drumspeed is of 2 byte.......
    if u have any questions please ask me...
    Eagerly awaiting for ur reply....
    Regards
    rajasekar
    Attachments:
    testing21.vi ‏442 KB

  • Datagrid Array Problem

    Hello to everyone who reads this. I've been on the forums
    over the past few days trying to track down my issue, but I cant
    seem to nail it down. I was hoping someone would have the time to
    help me out.
    Problem is this: Play list editor what all the information is
    stored in a mysql database. retrieving the information and passing
    it to flex and working with it in data grids has been relatively
    smooth. The problem happens when I attempt to drag files onto the
    playlist. It seems the information being passed is an array 'items'
    as it states in the docs, but in each array is xml associated with
    the file.
    ex:
    <file>
    <FK_File>752</FK_File>
    <filename>01 Summertime.mp3</filename>
    <filePath>/home/public/data/audio/Internal HDD-CORE
    (sda1) [42]/Various Artists/Summertime</filePath>
    <pic>
    http://dcerouter/pluto-admin/mediapics/5153_tn.jpg</pic>
    <Title>Summertime</Title>
    <genre PK_Attribute="73">Funk</genre>
    <performer PK_Attribute="308">Ohio
    Players</performer>
    <ReleaseDate
    PK_Attribute="229">2005</ReleaseDate>
    <Album PK_Attribute="311">Summertime</Album>
    <Track PK_Attribute="72">1</Track>
    </file>
    <file>
    <FK_File>1426</FK_File>
    <filename>02 Fantasy.mp3</filename>
    <filePath>/home/public/data/audio/Internal HDD-CORE
    (sda1) [42]/Earth, Wind &amp; Fire/Earth Wind &amp;
    Fire</filePath>
    <pic>
    http://dcerouter/pluto-admin/mediapics/270_tn.jpg</pic>
    <Title>Fantasy</Title>
    <genre PK_Attribute="73">Funk</genre>
    <performer PK_Attribute="762">Earth Wind &amp;amp;
    Fire</performer>
    <ReleaseDate
    PK_Attribute="765">1978</ReleaseDate>
    <Album PK_Attribute="766">Earth Wind &amp;amp;
    Fire</Album>
    <Track PK_Attribute="151">2</Track>
    </file>
    <file>
    <FK_File>1974</FK_File>
    <filename>02 Give Up The Funk (Tear The Roof Off The
    Sucker).mp3</filename>
    <filePath>/home/public/data/audio/Internal HDD-CORE
    (sda1) [42]/Parliament/Tear The Roof Off 1974-1980 (Disc
    2)</filePath>
    <pic>
    http://dcerouter/pluto-admin/mediapics/_tn.jpg</pic>
    <Title>Give Up The Funk (Tear The Roof Off The
    Sucker)</Title>
    <genre PK_Attribute="73">Funk</genre>
    <performer
    PK_Attribute="1150">Parliament</performer>
    <ReleaseDate
    PK_Attribute="731">1976</ReleaseDate>
    <Album PK_Attribute="1153">Tear The Roof Off 1974-1980
    (Disc 2)</Album>
    <Track PK_Attribute="151">2</Track>
    </file>
    Im assuming the comma separation from each child 'file',
    denotes the items are stored as an array. i don't know if i should
    attempt to send them back to php for processing of if im doing
    something wrong to begin with that the data comes out that way.
    Thanks in advance for any responses or insights.

    I'm not sure there is a proper way to do anything ( who
    decides this anyhow :) ) ....I guess it depends on what your doing
    and how efficient it is and whether it needs to scale to a massive
    system or not..otherwise if it works ...it works !
    I dont actually use php on the server side, i use java remote
    objects. and they return java collections...which i then cast to
    arraycollection in flex and access it that way...I'm not sure what
    the php equivalent is, some sort of array (cohesive ??) as you
    mentioned. I really like the way java and flex co-exist on the
    server & client. If i make a .as class for an object in flex, I
    then make the equivalent java class on the server so I can store it
    in the DB
    and do the CRUD stuff. I use keys a lot too, so i find my
    datagrids in flex often need itemrenderers / comboboxes to be able
    to choose the key values as options , so the combo items come
    straight out the DB too..anyway you get the gist..it sounds like
    your doing similar. I have done a little php before and I really
    liked how little code was required to do stuff. I think for me,
    I've done a bit of java before so its easier just to stay with what
    you know..glad you sorted it out yourself too.

Maybe you are looking for