If you've coded in objective c and java before...


L

laure

Hi!

I have a question about moving between java and objective c, sort of.
I have this new serial device and the person who originally coded for
serial to pc communication did so in objective c. From his code, to
launch a counter, you have to type in 'a' and to disable the counter
you have to type in 'd'...or that's what I gathered from it. Now I am
trying to access this device from hyperterminal and from java, on my
pc, and I am able to sense some communication using SerialDemo and
BlackBox, from the Java Communications API's samples ... (basically
with no comm port, auto-transmitting in the Serial Port Black Box
Tester would give some crazy high numbers in the baud rate window, but
with a comm port set to 9600, well... the baud rate stayed there. I'm
new to serial coding so please bear with me if I wrongly assumed that
from this 'experiment' my pc could to some degree detect some serial
communication :) )

To the actual problem... when I type a 'd' or an 'a', I get nothing
from the serial device. I don't get anything from it after typing
anything at all, actually. Not in the hyperterminal, not using
SerialDemo or Black Box... Is it normal? Could I be doing something
wrong?

If you have any suggestions about what could be going on, please feel
free to send them!

Thanks,

JL
 
Ad

Advertisements

M

Martin Gregorie

laure said:
Hi!

I have a question about moving between java and objective c, sort of.
I have this new serial device and the person who originally coded for
serial to pc communication did so in objective c. From his code, to
launch a counter, you have to type in 'a' and to disable the counter
you have to type in 'd'...or that's what I gathered from it.
>
By 'type in' I'll assume you mean 'send'.
Now I am
trying to access this device from hyperterminal and from java, on my
pc, and I am able to sense some communication using SerialDemo and
BlackBox, from the Java Communications API's samples ... (basically
with no comm port, auto-transmitting in the Serial Port Black Box
Tester would give some crazy high numbers in the baud rate window, but
with a comm port set to 9600, well... the baud rate stayed there. I'm
new to serial coding so please bear with me if I wrongly assumed that
from this 'experiment' my pc could to some degree detect some serial
communication :) )
For a serial device you need to have several parameters set:

- baud rate
- character length (5,6, 7, or 8 bits - 7 or 8 are most usual)
- parity (odd, even or none - if the character is 8 bits parity
must be none)
- stop bits (1, 1.5 or 2 - 1 is usually OK) this sets the gap
between characters.

You need all four set correctly or you'll either get corrupted
transmissions or nothing at all. Of course, if you're 'really lucky' the
device will be using synchronous transmission and the stop bits are
irrelevant.

Read the Objective C source to see where the program initializes the
serial port, decode the settings and make sure your terminal/Java code
uses the same settings.

Make sure the cable is correct. If it hasn't got all pins connected
end-to-end you can have flow control problems. If a crossover (null
modem) cable is needed, make sure you have one.
To the actual problem... when I type a 'd' or an 'a', I get nothing
from the serial device. I don't get anything from it after typing
anything at all, actually. Not in the hyperterminal, not using
SerialDemo or Black Box... Is it normal? Could I be doing something
wrong?
It might be correct. There's nothing in the rules of serial
communication to say that anything needs to be echoed when a character
is sent.

Its quite common to send a complete message without any response until
it has been completely received. Interactive sessions like terminals
talking to command shells usually echo every character sent, but you
wouldn't do that during, say, a file transfer because it would make
everything very slow. Instead you'd expect something like a single ACK
or NAK character after every block to say whether it was received OK or
was garbled during transmission and needs to be resent.

The commands you quote (starting and stopping a counter) may not
necessarily be acknowledged though that would be unusual. Is there
something on the device that you can monitor to see if what you're
sending has any effect such as an LED or an output you can monitor with
an oscilloscope or logic probe?

To know whether the device is accepting and understanding what you're
sending you'll need to read and understand the manual (if the device has
one) and/or to work through the Objective C program until you understand
all the commands that can be sent to the device and what responses it
can give for each command.

Put lots of logging in your Java program so it can trace every byte sent
to and received from the device. You'll need it! Check whether the
Objective C program has tracing/debugging code in it. If it has, turn
that on to max, run the program and analyze the tracing to understand
the commands and responses.

If all else fails, beg, borrow or buy a datascope and use that to
monitor the line between your computer and the device. That can show all
transmitted and received characters as well as the signal levels on the
flow control lines.
 
D

David Stes

In comp.lang.objective-c laure said:
I have a question about moving between java and objective c, sort of. [...]
If you have any suggestions about what could be going on, please feel
free to send them!

Objective-C doesn't seem such a bad choice, for serial comm. programming,
given the fact that a lot of such programming is being done in plain C,
of which Objective-C is a strict superset.

Sorry to ask, but why not just stick to Objective-C ?

Regards,
 
Ad

Advertisements

J

julielaurek

I have a question about moving between java and objective c, sort of. [...]
If you have any suggestions about what could be going on, please feel
free to send them!

Objective-C doesn't seem such a bad choice, for serial comm. programming,
given the fact that a lot of such programming is being done in plain C,
of which Objective-C is a strict superset.

Sorry to ask, but why not just stick to Objective-C ?

Regards,

No problem. I don't know objective-c; someone else took care of that
part and isn't here to help presently. i would have gladly used it
otherwise.
 

Top