|
|
| |
1. Update Packet Data Dynamically |
|
Reply |
|
|
 Kartik Patel | 2012-12-28 10:00:25 |
Hello Sir,
$packet .= "\x04";
$packet .= "\x00\x00\x00";
$packet .= "\x00\x00\x00\x00";
$packet .= "\x00\x00\x00\x00";
$packet .= "\x19\x02\x01\x02\x01\x01\x00\x03"; // Serial Number
This is my sample code. At last of the code it represents the serial number of my device, to which i have to send my packet.
My problem is that, If there are number of devices and device have their unique serial number. So i want to send packet with that number. and for that i m just fetch the serial number from database and just convert that code into hexcode
Decimal Serial Number : 25 2 1 2 1 1 0 3
Hec Serial Number : 19 02 01 02 01 01 00 03
This hex serial number is stored into $SR_NO;
and when i m going to call this variable instead of manually enter, it is not work.
$packet .= "\x04";
$packet .= "\x00\x00\x00";
$packet .= "\x00\x00\x00\x00";
$packet .= "\x00\x00\x00\x00";
$packet .= "$SR_NO";
but if I fill it manually
$packet .= "\x04";
$packet .= "\x00\x00\x00";
$packet .= "\x00\x00\x00\x00";
$packet .= "\x00\x00\x00\x00";
$packet .= "\x19\x02\x01\x02\x01\x01\x00\x03"; // Serial Number
it will work.
According to my application it is necessary to pur serial number dynamically
So can you please suggest me that how can i resolve my problem ?
Thanks
(Kartik Patel) |
| |
2. Re: Update Packet Data Dynamically |
|
Reply |
|
|
 Joshua hatfield | 2012-12-28 15:44:00 - In reply to message 1 from Kartik Patel |
| Sounds like to me that however you're converting your serial number isn't returning what you're expecting. What I imagine may be happening is that your hex conversion function is converting to numbers/letters and not to ascii which is what you really need. To test, you could echo $SR_NO to the screen or webpage. If you see numbers and/or letters, then it's your number conversion process. |
|