![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2005
Posts: 3
Rep Power: 0
![]() |
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} |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
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? |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Oct 2005
Posts: 3
Rep Power: 0
![]() |
The target system is a Win98 machine. The data was captured with a Win XP machine
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#5 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
__________________
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 |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|