64-bit Sensor Operation Example
1. Understanding the Script
Some sensors in the sensor list use 64-bit data. However, the script operates solely with 32-bit variables. Therefore, in order to read from or write to these sensors, the 64-bit values must be split into two 32-bit parts. Each half is then read or written separately.
64 bit variable:
0x1122334455667788
0x11223344 - 32 bit high value of a 64 bits (Bit64_high)
0x55667788 - 32 bit low value of a 64 bits (Bit64_low)
2. 64-bit Sensor Write Example
#include <io>
#include <read>
#include <float>
#include <string>
#include <core>
#include <write>
#include <define>
new low_32_write = 0x05;
new high_32_write = 0x556A88BB;
main()
{
set_val(SENSOR_U64_USER_DEFINED_0, low_32_write, Bit64_low); // Write lowest 32bit from 64bit (0x00000000FFFFFFFF)
set_val(SENSOR_U64_USER_DEFINED_0, high_32_write, Bit64_high); // Write highest 32bit from 64bit (0xFFFFFFFF00000000)
for(;;)
{
Delay(1000);
}
}3. 64-bit Sensor Read Example
#include <io>
#include <read>
#include <float>
#include <string>
#include <core>
#include <write>
#include <define>
#include <debug>
#define RS232_SPEED 115200
#define WORD_LENGTH WORDLENGTH_8
#define STOP_BITS STOPBITS_1
#define PARITY PARITY_NONE
new low_32_read = 0;
new high_32_read = 0;
main()
{
Init(RS232, RS232_SPEED, WORD_LENGTH, STOP_BITS, PARITY);
debug_init(RS232);
low_32_read = get_val(SENSOR_U64_USER_DEFINED_0, Bit64_low); // Read lowest 32bit from 64bit (0x00000000FFFFFFFF)
high_32_read = get_val(SENSOR_U64_USER_DEFINED_0, Bit64_high); // Read highest 32bit from 64bit (0xFFFFFFFF00000000)
debug_print("Ibutton ID: %08X%08X\r\n\r\n", high_32_read, low_32_read);
for(;;)
{
Delay(1000);
}
}