我是用workerman的mqtt和laravel发送的,请问publish的内容是不是2进制的?
protected function sendBinary($device, $start, $registerNum, $byteNum)
{
$str = $device->address . $device->deviceModel->read_code . $start . $registerNum;
$data = strToBinary($str); // 字符串转2进制
$crc = calculateModbusCRC($data); // 算出modbus rtu的crc码
$binaryData = hex2bin($str.$crc); // 将16进制字符串转换为二进制数据
$this->mqttClient->publish('/whd1/network/test/r/1234', $binaryData);
}