I have read a bit about the endian differences, got a couple of jar/libs to help (Android and com.mindprod), but still am not sure how to fix this program that I have (written in JDK 1.4 by someone else who is not here anymore). I have some complicated structures in this program that I don't know how to fix. I have fixed DataInputStream and DataOutputStrea m but using com.mindprod and now have LEDataInput and Output Streams (Little Endian). The purpose is to talk over sockets to a Linux program which is Little Endian, from a Java App which is BigEndian. The structures that I am not sure what to do with are (showing imports): java.io.InputSt ream, java.io.OutputS tream, toByteArray(), java.io.ByteArr ayOutputStream, java.io.ByteArr ayOutputStream, java.io.ObjectI nputStream, java.io.ObjectO utputStream. The program was elegantly written, very complicated, and I am not sure what is going to take more time. Fixing this to talk to Linux (LE), or re-writing parts of it with some of the new stuff in JDK 1.6, Android, etc. Anyone have any suggestions?
8 9978 JosAH 11,448
Recognized Expert MVP
A DataOutputStrea m always writes its data in big endian format. A DataInputStream always reads data in big endian format. If you couple the two streams between two machines there should be no problem at all. If your Linux box expects the data on the wire to be in little endian format don't use a DataOutputStrea m to write to the wire.
kind regards,
Jos
Well, not using DataInput or DataOutputStrea ms means a rewrite of a large and complicated program. In any case com.mindprod has LE versions of those. It's all the others in this program that cause all the problems.
Let me be clear: the Java program was originally developed to run on Solaris(Unix) and communicate with programs(call them simulator programs) on the same - and all are Big Endian. However, there has been a movement thru my company to replace Unix boxes with Linux ones, and the simulator programs have been migrated to Linux, but no one payed attention to the endianness problems. So, I am stuck with BE java not being able to communicate with LE Linux simulators. This also leaves me with a number of streaming formats that don't have LE replacements like DataInput & OutputStreams.
So I am still left wonder what to do.
JosAH 11,448
Recognized Expert MVP
Aren't all those simulator programs (running on those LE Linux boxes now) written using Java? If not I guess your best option is to use that LEDataOutputStr eam to send the data over in little endian format so your Linux (Intel?) boxes can read and understand the data.
Also you might look at the IntBuffer and ByteOrder classes although I don't know of any out-of-the-box solution right now; I'll think about it.
kind regards,
Jos
No, the simulators are written in ADA. They are unchangeable for all intents and purposes. The communication between the java and ada is on two separate sockets with very different formats.Fixing this problem is not as simple as I first thought as I have found inconsistent results when trying various standard coding methods such as swapping bytes etc.
I think this is going to take a while.
JosAH 11,448
Recognized Expert MVP
I bet these ADA programs write binary data back to that Java module? Right? And they write it back in LE form? Can I conclude that all your binary data communication must be done in LE form?
kind regards,
Jos
Yes, you can quite safely say that the data is binary and the Java must use LE binary data methods.
Thanks for helping. If you have any ideas let me know. All the work I've done has only produced inconsistent results so far.
JosAH 11,448
Recognized Expert MVP @marknvicf
If you can change the Java part of it all you can do the following:
1) find the file src.zip in your JDK installation and extract the files DataOutputStrea m.java and DataInputStream .java
2) Change the writeX and readX methods to their little endian equivalents; this is easy to do when you see the code of the original mehods: change the methods that write/read chars/shorts/ints and longs.
3) Rename the files to LEDataOutputStr eam.java and LEDataInputStre am.java and put them in another package.
4) Everywhere in your Java code use the two new classes (see above) instead of the original classes.
That should do the job ...
kind regards,
Jos
Jos,
Ok, first let me say that the ADA is in Linux on an Intel machine. The Java is on a PC, but I move the jar file to a location on the linux. Ok, here it is. One, there will not be funding to fix the foobar ADA code since they never gave thought to such things as I am encountering now. Everything was great when the ADA was on Unix(Solaris 8) on Unix boxes.
What I am encountering now makes simple endian conversion look like simple math compared to chaos theory. The bit streams are coming over in unknown formats and while I have been able to fix the headers that contain information about the data, I have not been able to fix the data. Simply put, and another extremely intelligent guy at work agrees with me, I would have to convert each packet of data differently (by packet I just mean each short or int or whatever). The overhead would kill the program by slowing it down to a crawl. That doesn't include the method by which the data and handshaking go back and forth. This has to do with the first socket which contains a type of information (can't tell anything about it - proprietary). The second I have had some actual success with as it is completely different from the first one, but still have some bugs to work out.
Endianess has gone from black box to simple as pie, on its own. I could write endian code all day in my sleep now. Too bad this problem is so screwy. I may just tackle the ADA side myself and looking into things like lhost etc. It's better to ask forgiveness than permission has been my motto for, oh, about 26 professional years now.
My aforementioned friend from work said that if I fix this problem, people all over the world will thank me. I think that is just geek talk for getting a white paper out of it.
thanks for all your previous help,
Mark
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Patrick |
last post by:
Hello all!
I am porting an application from C++ to Java and have run into a
problem using the DataInputStream reader object. The file I am trying
to read in is anywhere from 20 to 60 MB and has a short (25 lines or
so) ASCII text "header". The file structure is a double dimensioned
array of objects. The ASCII header defines how many...
|
by: hicham |
last post by:
Hi,
I am looking for help, i would like to know how can i use the endian.h and
config.h to convert compiled files under solaris from BIG-ENDIAN to compiled
files LITTLE-ENDIAN.
I am working under linux debian 3.0 woody
Thank you for your help.
|
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in C++. I find my self sometimes, trying
Object app = Object();
Object *app = Object();
Object app = new Object();
|
by: Gaurav |
last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250
Any comments?
Thanks
Gaurav
|
by: Richard |
last post by:
Level: Java newbie, C experienced
Platform: Linux and Win32, Intel
Another programmer and I are working on a small project together.
He's writing a server process in Java that accepts input from
processes I've written over a TCP connection. My processes are all
written in C; his are all done in Java. He's new to Java, and I've
never...
| |
by: glueless |
last post by:
I have to read files from UNIX systems on my PC. The problem
is that these binary files are in big endian and I need to convert
them. I saw that there are functions ntohl for my visual C++ (4.0),
but I don't know in what librarieses these are.
I want to kep the code as simple as possible, since I also want to
compile it on UNIX systems. Does...
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej and
I was wondering if anyone here would be able to give me some tips for
young players such as myself, for learning the language.
Is this the...
|
by: BillJosephson |
last post by:
Want to do OOP. Does c++ have all the abilities of java, or is it some
subset?
Thanks...
|
by: Ramesh |
last post by:
Hi
I have a structure as below on big endian based system
typedef struct
{
unsigned long LedA:5;
unsigned long LedB:4;
unsigned long LedC:8;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |