Helper tools
This commit is contained in:
parent
dba4e936e5
commit
18eabf3f0a
2941
docs/PowerLogic-PM8000/PM8000_Modbus_Map.h
Normal file
2941
docs/PowerLogic-PM8000/PM8000_Modbus_Map.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -17,14 +17,20 @@ typedef struct
|
||||
} pm8000_reg_map_t;
|
||||
|
||||
pm8000_reg_map_t pm8000_reg_map[] = {
|
||||
|
||||
[replace]
|
||||
};
|
||||
"""
|
||||
|
||||
lines = ""
|
||||
for d in range(1, len(data)):
|
||||
if not data[d][1].isnumeric():
|
||||
continue
|
||||
print("{} @ {}:{} ({}) Tag: {}".format(data[d][0], data[d][1] ,data[d][2] ,data[d][3],data[d][7]))
|
||||
|
||||
#print("{} @ {}:{} ({}) Tag: {}".format(data[d][0], data[d][1] ,data[d][2] ,data[d][3],data[d][7]))
|
||||
lines += " { " + data[d][1] + ", " + data[d][2] + ", \"" + data[d][3] + "\", \"" + data[d][0].encode('ascii',"ignore").decode('ascii') + "\" },\n"
|
||||
#
|
||||
|
||||
print(header.replace("[replace]", lines))
|
||||
|
||||
file = open("PM8000_Modbus_Map.h", "w")
|
||||
file.write(header.replace("[replace]", lines))
|
||||
file.close()
|
84
firmware/libs/wkfn/numbers.h
Normal file
84
firmware/libs/wkfn/numbers.h
Normal file
@ -0,0 +1,84 @@
|
||||
|
||||
unsigned int f_2uint_int1(float float_number) { // split the float and return first unsigned integer
|
||||
|
||||
union f_2uint {
|
||||
float f;
|
||||
uint16_t i[2];
|
||||
};
|
||||
|
||||
union f_2uint f_number;
|
||||
f_number.f = float_number;
|
||||
|
||||
return f_number.i[0];
|
||||
}
|
||||
|
||||
unsigned int f_2uint_int2(float float_number) { // split the float and return first unsigned integer
|
||||
|
||||
union f_2uint {
|
||||
float f;
|
||||
uint16_t i[2];
|
||||
};
|
||||
|
||||
union f_2uint f_number;
|
||||
f_number.f = float_number;
|
||||
|
||||
return f_number.i[1];
|
||||
}
|
||||
|
||||
float f_2uint_float(unsigned int uint1, unsigned int uint2) { // reconstruct the float from 2 unsigned integers
|
||||
|
||||
union f_2uint {
|
||||
float f;
|
||||
uint16_t i[2];
|
||||
};
|
||||
|
||||
union f_2uint f_number;
|
||||
f_number.i[0] = uint1;
|
||||
f_number.i[1] = uint2;
|
||||
|
||||
return f_number.f;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int l_2uint_int1(long long_number) { // split the long and return first unsigned integer
|
||||
|
||||
union l_2uint {
|
||||
long l;
|
||||
uint16_t i[2];
|
||||
};
|
||||
|
||||
union l_2uint l_number;
|
||||
l_number.l = long_number;
|
||||
|
||||
return l_number.i[0];
|
||||
}
|
||||
|
||||
unsigned int l_2uint_int2(long long_number) { // split the long and return first unsigned integer
|
||||
|
||||
union l_2uint {
|
||||
long l;
|
||||
uint16_t i[2];
|
||||
};
|
||||
|
||||
union l_2uint l_number;
|
||||
l_number.l = long_number;
|
||||
|
||||
return l_number.i[1];
|
||||
}
|
||||
|
||||
long l_2uint_long(unsigned int uint1, unsigned int uint2) { // reconstruct the long from 2 unsigned integers
|
||||
|
||||
union l_2uint {
|
||||
long l;
|
||||
uint16_t i[2];
|
||||
};
|
||||
|
||||
union l_2uint l_number;
|
||||
l_number.i[0] = uint1;
|
||||
l_number.i[1] = uint2;
|
||||
|
||||
return l_number.l;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user