LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2d array

Hi,
 
I want to read ascii bytes into an array. The data is from an Srecord file converted to asci bytes. I want to send the data from an array as 1K Xmodem but I need to get all the data from the Srecord into an array which includes the start character the data and the crc. The total number of bytes for chunk piece of data is 1029. I have no way of telling what size of array I need as each Srecord is different.
 
What I want to do is to put each chunk of data 1029 bytes into an array.
 
Example of what I want.
 
ARRAY(0,data 1029 bytes)
ARRAY(1,data 1029 bytes)
ARRAY(2,data 1029 bytes)
ARRAY(3,etc etc)
 
Can someone advise how to get the data into this type of array?
 
regards
 
Billy.
0 Kudos
Message 1 of 7
(3,124 Views)
Try using "string to byte array function"
0 Kudos
Message 2 of 7
(3,117 Views)
Hi Billy,
connect your file data (string) to a for loop. Use the "string subset" function with an offset of i*1029 and a length of 1029. Run the loop length(data) mod 1029 (maybe +1). Connect the output of "string subset" to the other side of the loop and you have your array.
 
Hope it helps.
Mike
0 Kudos
Message 3 of 7
(3,114 Views)
Welcome to my club billy
0 Kudos
Message 4 of 7
(3,109 Views)

Hi Mike, Muks,

 

thanks for the replies.

 

Mike, I have no problem getting each 1029 bytes of data from the file. I have a loop and it creates the following

ARRAY(Byte 1)

ARRAY(Byte 2)

etc etc

However, that only gets me 1029 bytes of data each time around the loop. I then need to put the 1029 bytes into another array so that I have say 10000 * 1029 bytes of data.

ARRAY(0,1029 bytes)

ARRAY(10000,1029 bytes)

regards

 

Billy.

 

 

0 Kudos
Message 5 of 7
(3,104 Views)

Hi Billy,

what do you mean? See the picture please. You will get an array and each element contains 1029 bytes.

Mike

0 Kudos
Message 6 of 7
(3,102 Views)
Hi Mike,
 
I would need to try it.
 
The 1029 bytes are not taken directly from the file.
 
They are as follows.
 
Byte(0) = STX which is the start of a 1K Xmodem packet.
Byte(1) = the packet number
Byte(2) = MOD 256 of the Packet number.
Next 1024 bytes are directly from the file but need to be converted to ascii.
Byte(1028) = CRC
Byte(1029) = MOD 256 CRC or something like that
 
Therefore, there are a few things that need to be calculated and that is why I created the 1D array to hold a block of 1029 bytes. I then want to put thousands of 1029 blocks into a 2D array so that I can pass this array out from the VI to use in a teststand sequence.
 
regards
 
Billy.
0 Kudos
Message 7 of 7
(3,095 Views)