Lua API Function and Module Reference
Function 'array.insert'
a = array.insert(a, [pos,] value)
Inserts element value at position pos in a, shifting up the elements a[pos] ···, a[#a]. The
default value for pos is #a+1, so that a call array.insert(a, x) inserts x at the end of
array a.
Function 'array.string_to_array'
a = array.string_to_array("this is string")
Converts a Lua string to a byte array. The length of the array corresponds to the number of string
characters.
Function 'array.array_to_string'
s = array.array_to_string(a)
Converts a byte array to a Lua string. Strings in Lua are not zero-terminated and can contain any
arbitrary binary data.
Function 'array.compile'
format = array.compile(s)
Generates a binary format string for array.repack() based on the given ASCII format string.
array.repack() allows a re-packaging of data bytes from one array into another. The format
string defines which bytes are used and how they are packed into the destination array.
Example:
-- copy 4 bytes to the destination array in opposite order
format = array.compile("#4,#3,#2,#1")
dest_array = array.repack(format, src_array)
-- this corresponds to
dest_array[1] = src_array[4]
dest_array[2] = src_array[3]
dest_array[3] = src_array[2]
dest_array[4] = src_array[1]
The format allows constant values in addition:
-- copy only 2 bytes from the source array
format = array.compile("#1,0,#2,0x55")
dest_array = array.repack(format, src_array)
-- this corresponds to
dest_array[1] = src_array[1]
dest_array[2] = 0
dest_array[3] = src_array[2]
dest_array[4] = 0x55
CAN@net NT/CANbridge NT User Manual
18 (22)
4.02.0332.20002 1.2 en-US
Need help?
Do you have a question about the IXXAT CAN@net NT and is the answer not in the manual?