URGENT RXTX SERIAL PORT

N

Nanou

Hello


This is my situation :
A PC under OS MandrakeLinux 10.1
A machine branched on the serial port
I use jdk1.5 and the rxtx API

Opening the port seems good, i send data to the machine but when i read
th response i have a buffer with bytes null.
I have tried to sniff the serial port but i don't understand the data i
intercept, i don't recognize my protocol !
I don't know how i can debug to know what's wrong.
Any help will be welcome.
Thanks

Nanou
 
C

Chris Uppal

Nanou said:
Opening the port seems good, i send data to the machine but when i read
th response i have a buffer with bytes null.

It sounds as if you may be ignoring the value returned from read(). (If not
then I have no suggestions, I know nothing about serial port comms)

-- chris
 
R

Richard Wheeldon

Nanou said:
Opening the port seems good, i send data to the machine but when i read
th response i have a buffer with bytes null.
I have tried to sniff the serial port but i don't understand the data i
intercept, i don't recognize my protocol !

Sounds like it might be a baud rate or similar setting issue.
What is it you're connecting to the machine ?
What os are you running ? Have you managed to get any serial
comms working before ?
I don't know how i can debug to know what's wrong.

Get yourself a hardware monitor - or make one yourself.
Just connect the rx/tx pins to a 3rd port and plug in
a separate computer. Run hyperterminal (or whatever)
on this and monitor the output,

Richard
 
J

JScoobyCed

Nanou said:
Hello


This is my situation :
A PC under OS MandrakeLinux 10.1
A machine branched on the serial port

I am not sure to understand the above two sentences. Your hardware
connect a PC (Mandrake) to a "machine". WHat's the machine: a computer?
a robot?
I use jdk1.5 and the rxtx API

I am not sure, I think I remember having seen an issue with rxtx and
j2se 1.5. But maybe it was not related to 1.5 itself.... Ok, forget that :)
Opening the port seems good, i send data to the machine but when i read
th response i have a buffer with bytes null.

Your code? At least what's the part of your code that open the ink and
write/read?
I have tried to sniff the serial port but i don't understand the data i
intercept, i don't recognize my protocol !

Sniff? How? You say you don't recognize your protocol: do you get
valid/formatted serial data at least? If you get something like garbage,
you might have a unsynchronized baud rate (one side is, say, 9600 bauds
and the other 2400)
I don't know how i can debug to know what's wrong.

Capture Exceptions, JUnit (eventually)
 
J

JScoobyCed

Oh, and by the way, try not to "SHOUT" in the subject of a post ("URGENT
RXTX SERIAL PORT" in capital letters is understood as "shouting").
When somebody "shout" on a newsgroup, it is usually ignored, seen as
unpolite.
If you need urgent help (then news group is not the best choice :)), try
to title something like:
"[Urgent] rxtx serial port"

This would capture the attention of much more people to help you ;)
But also note that "urgent" post are more likely to be ignored, as when
in emergency, the writter of the post gives often too few information.
Then people have to ask more details to be able to help, and the
response from the original writer is often "I solved it already. Thanks
for your concern." or something like that.

Good luck :)
 
N

Nanou

Hello

It's a machine made by an enterprise and this machine is connected to a
serial port of a PC.
The protocol is specified to this machine.
Under windows no problem to use the machine

My code is :
RXTXCommDriver driver = new RXTXCommDriver();
driver.initialize();
SerialPort port = driver.getCommPort("/dev/ttyS0", 1);
port.setInputBufferSize(32);
port.setOutputBufferSize(32);
port.setRTS(false);
port.enableReceiveTimeOut(1000);
InputStream is = port.getInputStream();
OutputStream os = port.getOutputStream();
ReadableByteChannel in = Channels.newChannel(is);
WritableByteChannel out = Channels.newChannel(os);
ByteBuffer buffer = ....
out.write(buffer);
ByteBuffer response = ByteBuffer.allocate(32);
in.read(response);

Also, i tried to use javax.comm for linux and i have the following
error:
Error loadingSolarisSerial: java.lang.unsatisfiedLinkError:
/usr/local/jdk1.2.0_01/jre/lib/i386/libSolarisSerialParallel.so:
libc.so.1 cannot open shared object file: no such file or directory
On my pc i have libc.so.6 and i can't use it.
Where can i found it ??

Thanks

Nanou
 
A

Andrew Thompson

But also note that "urgent" post are more likely to be ignored, as when
in emergency, the writter of the post gives often too few information.

Add to that..

- 'I read off-line, and won't post till next time I connect.
That will be too late so I won't bother responding at all.'
- Folks who will not respond to an urgent post on the basis that
the student/business should have had better planning (or be prepared
to pay a lot more money) for a solution.
- Other folks who will not respond to an urgent post based on the
perception that the OP is trying to pull a fast one by insisting
it is urgent and that they therefore take precedence over *any*
other post to the group.

To the OP. Putting 'urgent' is a *bad* idea.

People will respond to you when they read the post (and more politely),
just as they would if you marked it 'urgent', and you do not risk
alienating them. Don't forget, few if any people here actually *care*
if you miss a deadline. Ultimately that is your problem to deal with.

[ And please don't SHOUT in the title, or at all for that matter.. ]
 
C

Chris Uppal

Nanou said:
in.read(response);

I repeat my earlier observation: it looks as if you are ignoring the value
returned from read().

/Never/ do that.

-- chris
 
N

Nanou

Hello

Thanks for your response.
In fact, i don't ignore the valued return by read and write;
I want to write 5 bytes, the return value of write is 5
I want to read 2 bytes and read return 2 but the two bytes i read are
\0\0
I'm not sure the 5 bytes are really send to my robot and i'm not sure
it's my robot that respond \0\0
I don't know what happen exactely. The connection on /dev/ttyS0 seem
open and my robot is connected.

Nanou
 
D

Dale King

Nanou said:
Hello

It's a machine made by an enterprise and this machine is connected to a
serial port of a PC.
The protocol is specified to this machine.
Under windows no problem to use the machine

My code is :
RXTXCommDriver driver = new RXTXCommDriver();
driver.initialize();
SerialPort port = driver.getCommPort("/dev/ttyS0", 1);
port.setInputBufferSize(32);
port.setOutputBufferSize(32);
port.setRTS(false);
port.enableReceiveTimeOut(1000);
InputStream is = port.getInputStream();
OutputStream os = port.getOutputStream();
ReadableByteChannel in = Channels.newChannel(is);
WritableByteChannel out = Channels.newChannel(os);
ByteBuffer buffer = ....
out.write(buffer);
ByteBuffer response = ByteBuffer.allocate(32);
in.read(response);

I would suggest testing it without the channels and see if you can see
the data just using the input and output streams. I'd bet your problem
has to do with the use of channels.

I'm a little confused as well because your error message below seems to
indicate that you are using JDK1.2.0_01, but channels were not
introduced until JDK1.4.
Also, i tried to use javax.comm for linux and i have the following
error:
Error loadingSolarisSerial: java.lang.unsatisfiedLinkError:
/usr/local/jdk1.2.0_01/jre/lib/i386/libSolarisSerialParallel.so:
libc.so.1 cannot open shared object file: no such file or directory
On my pc i have libc.so.6 and i can't use it.
Where can i found it ??

Looks like you didn't follow the directions for installing the JCL with
RXTX. It looks like you installed all of the Solaris implementation of
JavaComm. According to the directions for JCL the only part of the
Solaris JavaComm is the Jar file. You don't need the .so file which is
part of your error message. You also don't want the
javax.comm.properties file that came with the Solaris JavaComm. It needs
to be replaced with one that points to the RXTXCommDriver. It's all
spelled out in the install instructions here:

http://www.geeksville.com/~kevinh/linuxcomm.html

However, I recommend against using the JavaComm API at all. Sun wanted
to make it some kind of standard, but they implemented it in a very
stupid way (which makes it difficult to use it with WebStart apps), left
bugs in it, did not create a Linux version, and they have refused to
touch the thing since JDK 1.1 days. I say everyone should forget Sun's
API and we should standardize on the gnu.io.rxtx API.
 
N

Nanou

Hello

I have test my program without using Channels and i have the same
problem.
My code is :
RXTXCommDriver driver = new RXTXCommDriver();
driver.initialize();
SerialPort port = driver.getCommPort("/dev/ttyS0­", 1);
port.setInputBufferSize(32);
port.setOutputBufferSize(32);
port.setRTS(false);
port.enableReceiveTimeOut(1000­);
InputStream is = port.getInputStream();
OutputStream os = port.getOutputStream();

ByteBuffer buffer = ....
os.write(buffer.array());
ByteBuffer response = ByteBuffer.allocate(32);
in.read(response.array());

I use the jdk1.5.0_01 (sorry for the 2 instead of 5).
I don't use javax.comm.properties and comm.jar with rxtx.jar.
I do directly in my program :
RXTXCommDriver driver = new RXTXCommDriver();
driver.initialize();

In fact i'm not sure that the bytes are really write and send to my
robot.
My robot receive command and response to this command.
When my robot receive a command, he do the action he receive like print
a ticket even if he don't respond. And for the moment he do nothing !!
The serial port in well /dev/ttyS0. I don't know if this required
particular configuration under linux.
My linux is Mandriva, rxtx is supported under Mandrake ??

Nanou
 
N

Nanou

When i use a sniffer i see that :
00 00 00 00 FE 00 00 80
00 E6 00 00 00 00 00 FE
00 00 80 00 E6 00 00 00

I know that 00 E 00 correspond to IRP_MJ_WRITE
It's possible that there is a synchronization problem between the
opening connection, the write and the read ??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top