require Exporter;
our @ISA = qw(Exporter);
-our @EXPORT = qw( modbus_crc16 $protocol read_parameter_frame );
+our @EXPORT = qw( modbus_crc16 $protocol read_parameter_frame write_parameter_frame );
use Data::Dump qw(dump);
return $frame . modbus_crc16($frame);
}
+sub write_parameter_frame {
+ my $params = join('', @_);
+
+ my $frame
+ = "\x5A" # header
+ . "\x0B" # protocol version
+ . "\x06" # function code
+ . pack("v", length($params)) # data length
+ ;
+
+ $frame .= $params;
+
+ return $frame . modbus_crc16($frame);
+}
1;
# 6. Protocol Format
0x04 Y axis angle f Float(4) R -90-90 / Y axis angle
0x09 X axis relative angle f Float(4) R -90-90 0 Return the X angle value according to the set relative zero
0x0A Y axis relative angle f Float(4) R -90-90 0 Return the Y angle value according to the set relative zero
-0x0C Sensor temperature s Word(2) R -32768-32767 / signed,sensor temperature =Data/100, unit \83
+0x0C Sensor temperature s Word(2) R -32768-32767 / signed,sensor temperature =Data/100, unit celsius
0x0D Power source voltage S Word(2) R 0~65535 / Voltage= Data/100, unit V
0x0E Heartbeat interval l DWord(4) R/W 60~2160000 86400 ZCT330E Interval at which the device periodically uploads data to the server
0x0F Failure interval l DWord(4) R/W 60~2160000 3600 ZCT330E Interval at which the device failure is retransmitted