Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 17th, 2005, 10:34 AM   #1
jloyd
Newbie
 
Join Date: Oct 2005
Posts: 3
Rep Power: 0 jloyd is on a distinguished road
Need help building number from bytes

I am in a bit of a situation. I am working with a Hurco Autobend 7 controller on a metal press brake (big bending machine) I am writing a program to transfer jobs to and from the controller. I have contacted Hurco and they ahve very little to tell me. The software is a blend of outsoucred code and in house customizing.

Anyway, my problem

The controller gives me a record package in a big byte array. This array contains all of the data for a particular job. Strings are store with there corresponding byte values, integers are store in two bytes, little endian. Floating point numbers are stored in 4 bytes (I assume little endian). I have tried to process the bytes using IEEE 745 type conversion but it fails. Are there any other methods out there?

Example data: 123.45 stored as {0x0E,0xFFFFFF87,0xFFFFFF9B,0x40}
jloyd is offline   Reply With Quote
Old Oct 17th, 2005, 12:30 PM   #2
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
Part of the arpanet package in most C installations, there are two functions in netinet/in.h in both windows and unix:

htons, ntohs which are designed to swap endianness for short integers -ie, two byte integers.

As for converting floating point - what is your OS?
jim mcnamara is offline   Reply With Quote
Old Oct 17th, 2005, 3:19 PM   #3
jloyd
Newbie
 
Join Date: Oct 2005
Posts: 3
Rep Power: 0 jloyd is on a distinguished road
The target system is a Win98 machine. The data was captured with a Win XP machine
jloyd is offline   Reply With Quote
Old Oct 18th, 2005, 8:33 AM   #4
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
Do you have a clue what format the data is in? Microsoft has different FP fornmats -
for example see:

http://support.microsoft.com/default...kb;en-us;11936
jim mcnamara is offline   Reply With Quote
Old Oct 18th, 2005, 8:43 AM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
0xFFFFFF87
That doesn't look like it would make a valid floating-point number (well, a non-extreme number), however one arranged it, by any common method of representation. If you can't discover the actual procedure used, you might toss us a few patterns and their known-correct values to diddle with. Include a positive and negative number with the same absolute magnitude.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC