hello
I have a question please help me
I have a file *.dat i read this and i like insert value in one array
in array
this is result
but i don’t have idea as realization
thank you all
hello
I have a question please help me
I have a file *.dat i read this and i like insert value in one array
in array
this is result
but i don’t have idea as realization
thank you all
Hello,
I’m not sure if I get the question right, but you want to read a dataobject (*.dat File) into an array. (?)
I would go with the dataobj library from Automation Studio.
First calling DataObjInfo() to get the ident and and then read it using DataObjRead().
At the DataObjRead() you can give the memory where the data is stored (=your array) and how much data should be read. (=either the size / length of the dataobject or the size of your array)
You can check the help for an readymade example.
BR Fabian
hello Fabian
The file is generator external is not dat file from b&r
the *.dat extension is generic
this is example
translation this file
03 = numbers lines
32 = command 20
36 = value 10
56 = command 20
5a = value 110
7a = command 20
7f & 7e = value 30000
9e = command 20
a4a3a2 = value 10000
the distance first command = 50 unit then every 36 unit you have 1 command
i need search the command and insert in array
thankyou
Hello Emanuele,
you’ll have to open and read the file using the FileIO library.
You can use the FileOpen and the FileReadEx. You can make the buffer large enough to fit your “normal” files. If you’re sure the size isn’t too big and it won’t change, make it fixed. If not you’ll have to implement multiple “read” cycles if one is not enough.
Best regards
hello marcel
thank you for your answer
but my problem is insert the parameters in hex format into an array with all elements
Well, hex is only a dataformat. If you wan’t Bytes, use a BYTE array for example. But the data is always the same in the memory. You can also use USINT / UINT values e.g. and still check the values against a matching HEX value in ST.
Could you describe a little better what exactly your problem is? What does not work out for you?
Hello Marcel
Excuse me for delay , but I prepare test
I read file correct
now is all perfect but have problem read parameter
Example
I have this value in Hex
in this case the value is in 2 word
Do you have idea for concatenate 2 array ??
thank you for support
I think the easiest way to handle this is with the memcpy function (or the B&R version, brsmemcpy). I can’t see the datatype of your byReadData array, but I’m assuming it’s an array of 1-byte values (e.g. BYTE). If you want to concatenate two bytes into one value, you can create a 2-byte variable (e.g. an INT) and copy two bytes from your BYTE array into the INT.
This would copy array elements 2 and 3 into your INT: brsmemcpy(ADR(varInt), ADR(byReadData[2]), 2)
A few things to keep in mind:
varInt
variable, you’ll need to make sure the memcpy doesn’t write past its boundsMore information about IEC datatypes can be found here. If you’re instead working in C, C data types are also available to use.
thank all people for support