kardenal Posted May 2, 2006 Share Posted May 2, 2006 Hi. I'm trying to get PHP to read a hex value. This value comes from an SMS message sendt by a logger. It has information of energyusage. The information is sendt in hex and is 112 char long but PHP codes (pack) this into a 12 char long ASCII string and i can't find a way decode (unpack) this to its originale form. Does anyone have any idea how i can get hold of the initial hex value?The SMS message: format definition from linux "gsmsmsd" command.Type of message: SMS messageMessage type: SMS-DELIVERSC address: '4792001000'More messages to send: 1Reply path: 0User data header indicator: 0Status report indication: 0Originating address: '4793002664'Protocol identifier: 0x0Data coding scheme: compressed fax message waitingSC timestamp: 05/01/2006 12:00:27 AM (+0200) User data length: [!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]112 [!--colorc--][/span][!--/colorc--]User data header: 0x User data: '[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]m741007ë,W[!--colorc--][/span][!--/colorc--]The "m741007ë,W" is a representation of the 112 chr hex string.The hex is 16 based.Anyone??? Quote Link to comment https://forums.phpfreaks.com/topic/8875-reading-hex/ Share on other sites More sharing options...
zq29 Posted May 2, 2006 Share Posted May 2, 2006 As far as I can work out, the 11 character ASCII string [b]'m741007ë,W[/b] would only convert to a 33 character hexadecimal string. Printable ASCII characters are 3 hex characters long I think. Can you post up any code that you are using to receive the user data? Quote Link to comment https://forums.phpfreaks.com/topic/8875-reading-hex/#findComment-32583 Share on other sites More sharing options...
kenrbnsn Posted May 2, 2006 Share Posted May 2, 2006 You are probably echoing the "User data string" and since it looks like the information contains binary (i.e. non characters) it most likely has some NULL characters (all zeroes) which stops a normal character string.Take a look at the functions [a href=\"http://www.php.net/pack\" target=\"_blank\"]pack()[/a] and [a href=\"http://www.php.net/bin2hex\" target=\"_blank\"]bin2hex()[/a]. One of them should give you what you're looking for.Ken Quote Link to comment https://forums.phpfreaks.com/topic/8875-reading-hex/#findComment-32607 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.