ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: java recommendations

To:
Subject: Re: [ts-7000] Re: java recommendations
From: Dave Cramer <>
Date: Tue, 7 Aug 2007 17:52:19 -0400
I think I also modified their source code to deal with putting the port into raw mode.

Chris can give your our rxtx libraries.

Dave
On 6-Aug-07, at 1:31 PM, tedapt wrote:

I'm trying to use /dev/ttyAM0 to communicate with another device using
the Modbus protocol. My Java application runs as a Modbus master,
connects to the other device which acts as a Modbus slave.

! My setup is:
- a TS-7250 (only COM1 is wired)
- Debian Sarge loaded from a USB drive
- JamVM
- rxtx 2.1 (with a symlink created from /dev/ttyAM0 to /dev/ttySO) to
allow rxtx to find the port

I appear to be able to find and write to the serial port, but fail
when trying to read.

I've removed jumper JP2, commented out the line in /etc/inittab that
initializes getty on /dev/ttyAM0. I've confirmed that there are no
getty processes running on /dev/ttyAM0 (ps -ef | grep getty) also
modified by RedBoot startup script to use ttyAM1 as the console
instead of ttyAM0.

I notice that stty gives different output before and after I attempt
to run my application. Do I need to configure the serial port through
Debian somehow? This is the output from stty:

Before application attempt:

:root# stty -F /dev/ttyAM0
speed 115200 baud; line = 0;
min = 1; time = 0;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

After application attempt:

:hawkeye# stty -F /dev/t! tyAM0
speed 9600 baud; line = 0;
min = 0; time = 2;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

Thanks for your help!

--- In .com, Christopher Friedt <cfriedt! @...> wrote:
>
> Hmm...
>
> What exactly are you trying to do with /dev/ttyAM0 ? Is it just to
get a
> console on the device? if so, you might have to add it to
/etc/securetty
> as well.
>
> ~/Chris

>
> tedapt wrote:
> > Ugh! Editing the getty setup lines in /etc/inittab didn't fix it,
> > still cannot read on /dev/ttyAM0. Anything else you had to do to
> > configure the port, like use stty to tweak the port settings or
> > something similar?
> >
> > Are you also running Debian on a TS-7250 loaded from a USB drive?
> > That adds a level of complexity for me, as I have to allow getty to
> > use /dev/ttyAM0 until I get Debian running or the script that enables
> > USB modules won't load (/usr/bin/loadUSBModules.sh), then I can kill
> > the getty process. But I wonder if that script may somehow hang onto
> > the port?
> >
> > --- In .com, justin@ wrote:
> >> yes, after the os boots you will no longer have com access. If you
> >> remove the jumpers on the board, jp2? It will prevent console on
the
> >> com during the boot. You could just comment out com1 and send the
> >> console stuff to com2. I needed both so I had to ditch the console.
> >>
> >> Justin
> >> Quoting tedapt <tedapt@>:
> >>
> >>> great! will give this a try in a few days when back on my
system. Did
> >>> a quick search on /etc/inittab, from what I gather this contains
> >>> instructions for starting up the getty process to manage user logins
> >>> on the console via the serial port(?) If that's right, do you think
> >>> commenting it out will prevent use of the serial port for accessing
> >>> the board (handy when ethernet is unavailable)?
> >>>
> >>> --- In .com, justin@ wrote:
> >>>> Got it to work. You have to disable the consol on the com ports.
> >>>> Look at your /etc/inittab. Comment out any lines with the com
> >>> ports
> >>>> name in it. I am using b! oth ports so I commented out both: ttyAM0
> >>> and
> >>>> ttyAM1.
> >>>>
> >>>> Quoting tedapt <tedapt@>:
> >>&! gt;>
> >>>>> OK, I'll let you know whatever I find too. Won't be able to get
> >>> back
> >>>>> to this and retest for a few days though. My test plan is to
> >>> write a
> >>>>> Java app that will listen for data on the serial port, and echo it
> >>>>> when received.
> >>>>>
> >>>>> One thing I've noticed is that if I try to start a listening app
> >>> on
> >>>>> the port it seems to lock the port at the OS level. I was then
> >>> unable
> >>>>> to access the port through the command line (e.g., echo
> >>>>>> /dev/ttyS0). Wonder if this ! may be related to the read problem?
> >>> If
> >>>>> that's so, wonder if there's a way to share the port between
> >>> multiple
> >>>>> clients?
> >>>>>
> >>>>> --- In .com, justin@ wrote:
> >! ;>>>>> Hey,
> >>>>>>
> >>>>>> Yeah, I am having a similar problem. I can write just fine. I
> >>> set
> >>>>> up
> >>>>>> a comm connection to the hyper term. But I can't receive
> >>> anything
> >>>>>> back. I'll let you know what I find. I ended up building my own
> >>>>> rxtx
> >>>>>> lib! , but same problem so I don't think thats the issue.> >>>>>>
> >>>>>>
> >>>>>> Quoting tedapt <tedapt@>:
> >>>>>>
> >>>>>>> thanks Justin. I seem to have had some limited success with
> >>> rxtx
> >>>>> 2.1
> >>>>>>> (the one you mention first) by simply creating a symlink
> >>>>>>! > from /dev/ttyAMO to /dev/ttyS0 (ln -s /dev/ttyAM0 /dev/tt! yS0).
> >>>>> Still
> >>>>>>> having problems communicating with a Modbus device, but
> >>> otherwise
> >>>>>>> Java is acting like it finds and can open the serial port (of
> >>>>> course
> >>>>>>> my "solution" may be part of the problem!)
> >>>>>>>
> >>>>>>> Current problem is that though my app claims to open
> >>> connections
> >>>>> and
> >>>>>>> make Modbus requests on /dev/ttyS0, I'm unable to get a
> >>> readable
> >>>>>>> response back (this code works properly on another platform).
> >>> I
> >>>>> need
> >>>>>>> to do some further testing with some simple Serial code to
> >>> prove
> >>>>! ;> to
> >>>>>>> myself I can really write and read with the port properly.
> >>>>>>>
> >>>>>>> I'm wondering if I need to configure my serial port somehow
> >>> (not
> >>>>> very
> >>>>>>> experienced with serial ports, not sure if that's required or
> >>>>> takes
> >>>>>>> care of itself). My app sets connection params of 9600 baud, no
> >>>>>>> parity, 8 data bits, 1 stop bit. Anyone know if the linux
> >>> system
> >>>>>>> (perhaps using stty) needs to configure the port to match this,
> >>>>> or is
> >>! ;>>>>> it only the client app at the other end of the communication
> >>> that
> >>>>>>> needs to match the same parameters?
> >>>>>>>
> >>>>>>> Also, I'm using JamVM, so my RXTXcomm.jar wa! s placed
> >>>>>>> in /usr/lib/jamvm (also where I placed librxtxSerial.so)
> >>>>>>>
> >>>>>>> Further, I was unable to enumerate the serial ports using rxtx
> >>>>> 2.0.
> >>>>>>> I would settle for a working rxtx 2.1 solution, and from the
> >>> rxtx
> >>>>>>> documentation it seems that rxtx 2.1 is the preferred solution
> >>>>> when
> >>>>>>> possible to use it (i.e., when have ability to import gnu.io
> >>>>> classes
> >>>>>>> instead of javax.comm).
> >>>>>>>
> >>>>>>> --- In .com, justin@ wrote:
> >>>>>>>> I am working on the same thing, didnt want to respond till I
> >>> an
> >>>>>>> answer
> >>>>>>>> You can download the most current version of the arm-unknown-
> >>>>> linux-
> >>>>>>>! ; gnu
> >>>>>>>> binary at rxtx site:
> >>>>>>>> ftp://ftp.qbang.org/pub/rxtx/ToyBox/2.1-7-build1/Linux/glibc-
> >>>>>>> 2.3.5/arm-unknown-linux-gnu/
> >>>>>>>> The easyest way to add the ttyAMx com ports is to set the
> >>> system
> >>>>>>> properties:
> >>>>>>>> jamvm -Dgnu.io.rxtx.SerialPor! ts=/dev/ttyAM0:/dev/ttyAM1 foo
> >>>>>>>>
> >>>>>>>> The other way:
> >>>>>>>> RXTXComm! Driver.java is
> >>>>>>>> available in ftp://ftp.qbang.org/pub/rxtx/rx tx-2.0-7pre2/src/
> >>>>>>> Download the
> >>>>>>>> RXTXCommDriver.java. In this code, you will find
> >>>>>>>>
> >>>>>>>> if (osName.equals ("Linux")) { String[]Temp = { "ttyS", //
> >>> linux
> >>>>>>> Serial
> >>>>>>>&! gt; Ports "ttySA" // for the IPAQs }; CandidatePortPrefix es =
> >>> Temp;
> >>>>>>>> Replace this code with
> >>>>>>>>
> >>>>>>>> if (osName.equals ("Linux")) { String[]Temp =
> >>>>>>> { "ttyS", "ttyAM", // linux
> >>>>>>>> Serial Ports "ttySA" // for the IPAQs };
> >>> CandidatePortPrefixes =
> >>>>>>> Temp; }
> >>>>>>>> Compile the RXTXCommDriver.java and add the resulting
> >>>>>>> RXTXCommDriver.class
> >>>>>>>> file to RXTXcomm.jar
> >>>>>>> in /usr/java/jdk1.5.0_07/jre/lib/ext/RXTXcomm.jar
> >>>>>>>> Hope this help,
> >>>>>>>> Justin
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Quoting tedapt <tedapt@>:
> >>>>>>>>
> >>>>>>>>> Can anyone clarify Dave's statement about the use of rxtx:
> >>>>>>>>>! < BR style="font-family: Georgia; font-size: 13px; line-height: 15px; ">> >>>>>>>>> > note: you have to add the arm's /dev/ttyAMx to rxtx, it
> >>>>>>> doesn't
> >>>>>>>>> know about them
> >>>>>>>>>
> >>>>>>>>> Also, any notes from anyone who has successfully setup and
> >>> used
> >>>>>>> rxtx
> >>>>>>>>> with jamvm would be appreciated!
> >>>>>>>>>
> >>>>>>>>> The setup I'm attempting to get working is:
> >>>>>>>>>
> >>>>>>>>> - TS-7250
> >>>>>>>>> - debian on a USB thu! mbdrive
> >>>>>>>>> - jamvm installed via apt-get
> >>>>>>>>> - downloaded rxtx rxtx-2.0-7pre1 for Linux from:
> >>>>>>>>> http://users.frii.com/jarvi/rxtx/download.html (file
> >! >> at
> >>>>>>>>> ftp://ftp.qbang.org/pub/rxtx/rxtx-2.0-7pre1-i686-pc-linux-
> >>>>>>> gnu.tar.gz)
> >>>>>>>>> - extracted librxtxSerial.so and placed it
> >>> in /usr/lib/jamvm
> >>>>>>>>> - using Sun's comm.jar (from a Java 1.3 distribution)
> >>>>>>>>>
> >>>>>>>>> When I invoke the test class (source below) I get these
> >>>&g! t;> r esults:
> >>>>>>>>> root# /usr/bin/jamvm -cp .:comm.jar
> >>> SerialTest /dev/ttyAM0
> >>>>> 9600
> >>>>>>>>> Specified serial port (/dev/ttyAM0) does not exist
> >>>>>>>>> null
> >>>>>>>>> javax.comm.NoSuchPortException
> >>>>>>>>> at
> >>>>>>>>>! ; javax. comm.CommPortIdentifier.getPortIdentifier
> >>>>>>> (CommPortIdentifier.java:105)
> >>>>>>>>> at SerialTest.main(SerialTest.java:32)
> >>>>>>>>>
> >>! ;>> ;>>>>> Here's source for SerialTest.java:
> >>>>>>>>>
> >>>>>>>>> import java.io.IOException;
> >>>>>>>>> import java.io.InputStream;
> >>>>>>>>> import java.io.OutputStream;
> >>>>>>>>> import java.util.Enumeration;
> >>>>>>>>>
> >>>>>>>>> import javax.comm.CommPortIdentifier;
> >>>>>>>>> import javax.comm.NoSuchPortException;
> >>>>>>>>> import javax.comm.PortInUseException;
> >>>>>>>>> import javax.comm.SerialPort;
> >>>>>>>>> import javax.comm.UnsupportedCommOperationException;
> >>>>>>>>>
> >>>>>>>>> public class SerialTest {
> >>>>>>>>>
> >>>>>>>>> private static SerialPort sp;
> >>>>>>>>> private static InputStream sin;
> >>>>>>>>> private static OutputStream sout;
> >>>>>>>>>
> >>>>>>>>> public static void main(String[] args) {
> >>>>>>>>> try {
> >>>>>>>>> if (args.length != 2)! {
> >>>>>>>>> System.out.println("Usage:
> >>> java
> >>>>>>> SerialTerm.tini port_name data_rate");
> &g t;>>>>>>>> System.out.println("Available
> >>> ports
> >>>>>>> are:\n");
> >>>>>>>>> Enumeration ports =
> >>>>>>> CommPortIdentifier.getPortIdentifiers();
> >>>>>>>>> while(ports.hasMoreElements())
> >>> {
> >>>>>>>>> System.out.println
> >>>>>>> (ports.nextElement() + "\n");
> >>>>>>>>> }
> >>>>>>>>> System.exit(1);
> >>>>>>>>> }
> >! >>>>>>>> String portName = args[0];
> >>>>>>>>> int baudRate = Integer.parseInt(args[1]);
> >>>>>>>>> try {
> >>>>>>>>> sp =
> >>>>>>>>> (SerialPort)CommPortIdentifier.getPortIdentifier
> >>> (portName).open
> >>>>>>> ("SerialTerm",
> >>>>>>>>> 5000);
> >>>>>>>>> sp.setSerialPortParams(baudRate,
> >>>>>>> SerialPort.DATABITS_8,
> >>>>>>>>> SerialPort.STOPBITS_1,
> >>>>>>>>> Seri! alPort.PARITY_NONE);
> >>>>>>>>> sin = sp.getInputStream();
> >>>>>>>>> sout = sp.getOutputStream();!
> >>>>>>>>> } catch (NoSuchPortException nsp) {
> >>>>>>>>> System.out.println("Specified serial port
> >>>>> ("+portName+
> >>>>>>>>> ") does not exist");
> >>>>>>>>> throw nsp;
> >>>>>>>>> } catch (PortInUseException piu) {
> >>>>>>>>> System.out.println(! "Serial port "+portName+
> >>>>>>>>> " in use by another
> >>>>> application");
> >>>>>>&g! t;>&g t; throw piu;
> >>>>>>>>> } catch (UnsupportedCommOperationException usc) {
> >>>>>>>>> System.out.println("Unable to configure
> >>>>>>> port:"+portName);
> >>>>>>>>> throw usc;
> >>>>>>>>> } catch (IOException ioe) {
> >>&g! t;>>>>>> System.out.println(
> >>>>>>>>> "Unable to acquire I/O
> >>> streams
> >>>>> for
> >>>>>>> port
> >>>>>>>>> " + portName);
> >>>>>>>>> throw ioe;
> >>>>>>>>> }
> >>>>>>>>> } catch (Exception e) {
> >>>>>>>>> Sys! tem.out.println(e.getMessage());
> >>>>>>>>> e.printStackTrace();
> >>>>>>>>> }
> >>>>>>>>> }
> >>>>>>>>>
> >>>>>>>>> }
> >>>>>>>>>
> >>>>&g! t;>&g t;>> --- In .com, Dave Cramer <davec@> wrote:
> >>>>>>>>>> I've been running jamvm on mine for quite a while. You
> >>> don't
> >>>>> need
> >>>>>>>>>> jikes, unless you plan to compile on the arm (Very slow)
> >>>>>>>>>> I pulled alot of the gnuclasspath out, and the whole thing
> >>> is
> >>>>>>> quite
> >>>>>>>>>> small. Around 4M or so
> >>>>>>>>>>
> >>>>>>>>>> you need rxtx for serial port work with java,, other than
> >>> that
> >>>>>>> it's
> >>>>>>>>>> write once deploy everywhere
> >>>>>>>>>>
> >>>>>>>>>> no! te: you have to add the arm's /dev/ttyAMx to rxtx, it
> >>>>> doesn't
> >>>>>>> know
> >>>>>>>>>> about them
> >>>>>>>>>>
> >>>>>>>>>> Dave
> >>>>>>>>>> On 7-Nov-06, at 8:57 PM, gunghoiguana wrote:
> >>>>>>>>>>
> >>>>>>>>>>> The install was much easier than I anticipated:
> >>>>>>>>>>>
> >>>>>>>>>>> apt-get install jikes
> >>>>>>>>>>> apt-get install jamvm
> >>>>>>>>>>> apt-get install jikes-classpath
> >>>>>>>>>>>
> >>>>>>>>>>> Everything seems to work fine, and I can run class files
> >>>>> that I
> >>>>>>>>>>> compiled on my desktop PC. I've only checked out basic
> >>>>>>>! ; functi ons and
> >>>>>>>>>>> console IO so far, but I'll be checking out the serial
> >>> port
> >>>>> and
> >>>>>>>>>>> network interfaces soon. Java is *supposed* to make those
> >>>>>>> things
> >>>>>>>>>>> easy...
> >>>>>>>>>>>
> >>>>>>>>>>> Brian
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>
> >>>>>
> >>>
> >>>
> >
> >
> >
>


__._,_.___


SPONSORED LINKS
Single board computer Hardware Computer running slow
Linux os Single board

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU