服务端连接成功 普通数据能发送成功接收成功, 怎么发送和接收16进制的数据呀? 比如说我要服务端发送16进制数据 00 00 00 00 00 00 01 03 00 00 00 02 服务端给回复16进制数据 00 00 00 00 00 00 01 03 04 01 0F 03 14
已解决 去除空格后,转二进制发送就可以了
//$sendStr ='00 00 00 00 00 00 01 03 04 01 0F 03 14'; $hexdata='000000000000010304010F0314'; $bindata=''; for ($i=0;$i < strlen($hexdata);$i+=2) { $bindata.=chr(hexdec(substr($hexdata,$i,2))); } GatewayLib::sendToClient($client_id, $bindata);
已解决
去除空格后,转二进制发送就可以了
//$sendStr ='00 00 00 00 00 00 01 03 04 01 0F 03 14';
$hexdata='000000000000010304010F0314';
$bindata='';
for ($i=0;$i < strlen($hexdata);$i+=2) {
$bindata.=chr(hexdec(substr($hexdata,$i,2)));
}
GatewayLib::sendToClient($client_id, $bindata);