Reading form serial port problem

I'm using javax.comm for communicating with a microcontroller (the uc just sends data ->"data from uc"). Here is what is read from the serial port. Where is the problem?
the code:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.comm.*;
public class ss extends Frame implements WindowListener,ActionListener,KeyListener {
     TextField text = new TextField(20);
     Button inainte;
     Button inapoi;
     Button stanga;
     Button dreapta;
     Button stop;
SerialPort serialPort1, serialPort2;
test2 df=new test2();
     Label msg_stop=new Label("am un obiect in fata! ");
     TextArea displayArea;
     Panel panel;
     Panel displayPanel;
     Integer i;
     /*     public static void main(String[] args)
          test df=new test();
          //     df.dumpFrame();
               df.sendCommand("a");
          System.out.println("serial port successfully opened!");
     CommPortIdentifier portId1;
     CommPortIdentifier portId2;
     class test2 extends Thread
          serialComm mySerial;
          char var_ser,a;
          public String misc;
          test2()
                    try {
                         portId1 = CommPortIdentifier.getPortIdentifier("COM1");
                         portId2 = CommPortIdentifier.getPortIdentifier("COM2");
                         // cs a=new cs();
               catch
                    (Exception e) {
                    // TimeStamp = new java.util.Date().toString();
                    // System.out.println(TimeStamp + ": COM1 " + portId1);
                    // System.out.println(TimeStamp + ": COM2 " + portId2);
                    // System.out.println(TimeStamp + ": msg1 - " + e);}
                    try{             
     // serialPort1 = (SerialPort) portId1.open("ss", 2000);
          catch
     (Exception e2){};
               mySerial=new serialComm("1");
          // serialPort1=(SerialPort)mySerial;
     public void run()
          while(true) {
               // var_ser=mySerial.readByte();           
               // mySerial.writeStr("!andi");
               //try{
               //     sleep(200);
               // }catch(InterruptedException e){};
               a=mySerial.readByte();
System.out.println(a);
          //     if(var_ser=='r') {
          //          System.out.println("dsadsa");
          //     mySerial.writeStr(misc);     
          //     misc="id";
          //     if(var_ser=='o'&& misc=="sp"){
          //     misc="id";
          //     msg_stop.setVisible(true);
          // System.out.println("Sunt in task1 "+misc+" "+var_ser+" end ");
          try{
               sleep(200);
          }catch(InterruptedException e){};
     Flushes all data out of the serial file buffer
     int pixels[];
     public void dumpFrame()
          char a,c,k,r;
          int data=1, pix;
          int row,col=0;
          int count=0;
     //     pixels=new int[900];
     //     MemoryImageSource source;
     //     Image image;
     //          source = new MemoryImageSource(30,30,pixels,0,30);
     //          source.setAnimated(true);
     //          image=createImage(source);
          //     source.newPixels(0,0,30,30);
     //     mySerial.writeStr("DF\r");
          while(col==0){
          data=mySerial.readNonBlock();
          System.out.println(data);
          if(data==1) // New frame
               System.out.println("este 1 ! !");
          else
     if(data==2) // New col
          System.out.println("este 2 ! !");
          System.out.println("count este : "+count);
          count=0;
     else
          count++;
          /* else{
               if (data==0) {
                    'System.out.println("count este"+count);
          // if(!sendCommand("DF\r")) return 0;
          /* sendCommand("L1 1");
               //data=mySerial.readNonBlock();
          while(data!=0)
               sendCommand("L1 1");
               if(data==1) // New frame
                    col=0;
                    row=0;
               else if(data==2) // New col
                    col+=2;
                    row=0;
               else if(data==3) // End frame
                    row=0;
                    col=0;
               //     return 0;
               else
               {  // A pixel!
                    int red,green,blue,green2;
                    red=data;
                    green=mySerial.readByte();
                    blue=mySerial.readByte();
                    green2=green;
                    pix=0;
                    pix+=blue;
                    pix+=green<<8;
                    pix+=red<<16;
                    Color pixColor= new Color(pix);
                    pix=0;
                    pix+=blue;
                    pix+=green2<<8;
                    pix+=red<<16;     
                    Color pixColor2= new Color(pix);
          //     data=mySerial.readNonBlock();
          public void sendCommand(String command)
          char a,c,k,r;
          a=0;
     //     mySerial.writeStr("DF\r");
          //mySerial.writeStr("1");
          while(true){
               try
          a=mySerial.readByte();
     //     if (a=='r') {
          //mySerial.writeStr("!and");
     //     'a=0;
          //     System.out.println(trimit !!!");
               //     mySerial.writeStr(command);
//     a=mySerial.readByte();
          //     c=mySerial.readByte();
     //          k=mySerial.readByte();
     //     r=mySerial.readByte();
          //     if(a=='A' && c=='C' && k=='K' && r=='\r' )
                    //return true;
          //     else
               //     return false;
          }catch(Exception e) {System.out.println(e);}
          //return false;
          System.out.println(a);
     private int numClicks = 0;
public void keyTyped(KeyEvent e) {
     int keyCode = e.getKeyCode();
     System.out.println("Buton Apasat !"+keyCode);
/** Handle the key pressed event from the text field. */
public void keyPressed(KeyEvent e) {
     int keyCode = e.getKeyCode();
     System.out.println("Buton Apasat !"+keyCode);
     switch(keyCode){
     case 38: df.misc="fa";
/** Handle the key released event from the text field. */
public void keyReleased(KeyEvent e) {
public ss(String title) {
          super(title);
//      df.dumpFrame();
//     df.sendCommand("a");     
          //df.start();
//          df.misc="id";
     //     test2 df=new test2();
          //     df.dumpFrame();
     //     df.sendCommand("a");
          Panel panel = new Panel();
     Panel displayPanel = new Panel();
          addWindowListener(this);
     //     displayPanel
          displayPanel.add(panel);
     //     text.addKeyListener(this);
          inainte = new Button("Inainte");
          inapoi = new Button("Inapoi");
          stanga = new Button("Stanga");
          dreapta = new Button("Dreapta");
          stop = new Button("Stop");
          panel.setLayout(new BorderLayout());
     msg_stop.setBackground(Color.red);
     msg_stop.setFont( new Font ( "Dialog", 30, Font.ROMAN_BASELINE ));
          msg_stop.setVisible(false);
     displayArea = new TextArea(5, 20);
          //panel.add(displayArea);
     panel.setLayout(new BorderLayout());
          panel.add(inainte,BorderLayout.NORTH);
          panel.add(inapoi,BorderLayout.SOUTH);
          panel.add(stanga,BorderLayout.WEST);
          panel.add(dreapta,BorderLayout.EAST);
          panel.add(stop);
          //panel.add(msg_stop,BorderLayout.EAST);
          //panel.add(text);
          this.add("Center",displayPanel);
          inainte.addActionListener(this);
          inapoi.addActionListener(this);
          stanga.addActionListener(this);
          dreapta.addActionListener(this);
          stop.addActionListener(this);
          this.setVisible(true);     
          inainte.addKeyListener(this);
          inapoi.addKeyListener(this);
          stanga.addKeyListener(this);
          dreapta.addKeyListener(this);
          stop.addKeyListener(this);
     //     addKeyListener(this);
     //     displayArea.addKeyListener(this);
     public static void main(String[] args) {
          ss myWindow = new ss("Boe Bot " +
                    "Control");
          //myWindow.setSize(300,300);
          myWindow.setLocation(400, 200);
          myWindow.setSize(200,300);
          myWindow.setVisible(true);
     public void actionPerformed(ActionEvent e) {
          String command=e.getActionCommand();
     if(command.equals("Inainte")){
          System.out.println("Inaite !!! ");     
          df.misc="fa";}
     if(command.equals("Inapoi")){
          System.out.println("Inapoi !!! ");     
          df.misc="sp";}
     if(command.equals("Stanga")){
          System.out.println("Inapoi !!! ");     
          df.misc="st";}
     if(command.equals("Dreapta")){
          System.out.println("Dreapta !!! ");     
          df.misc="dr";}
     if(command.equals("Stop")){
          System.out.println("Stop !!! ");     
          df.misc="id";}
     //     numClicks++;
     //     text.setText("Button Clicked " + numClicks + " times");
     public void windowClosing(WindowEvent e) {
          dispose();
          System.exit(0);
     public void windowOpened(WindowEvent e) {}
     public void windowActivated(WindowEvent e) {}
     public void windowIconified(WindowEvent e) {}
     public void windowDeiconified(WindowEvent e) {}
     public void windowDeactivated(WindowEvent e) {}
     public void windowClosed(WindowEvent e) {}
thanks,
andi

from the screenshot it looks like there is 2 bytes of "noise" after every 8 bytes?
print the char array next to the String. are the 2 bytes of noise the same every time?

Similar Messages

  • A problem about reading from serial port

    Hi,
       I just sent '0x03' from MCU to PC continuously, and then sent  '/n' as a stop character after every '0x03'. I use labview to read the data. The problem is when it get two '03' it get a '0', another two '03' and another a '0'. I don't know where is the '0' from?
      PS: Hyper terminal can display natrually.
       Thank you! 
    帖子被hengfo在08-08-2007 10:14 PM时编辑过了
    Attachments:
    serial read.vi ‏36 KB

    I think the problem may be the loop reading the serial port is running too fast.  There is no timing delay in the loop, so you are reading it as fast as you can, and probably faster than the device is sending data.  So sometimes the buffer is empty, and then the empty string gets converted to a numeric zero.  The way to know for sure is to put an indicator on the error wire coming out of the serial port read.  I bet you will see errors about the read buffer being empty.
    Put a wait timer in the loop to slow down the execution just slightly.  This is a good idea so that LV doesn't eat up all the CPU resources.  Look at the example for Basic Serial Write and Read.  You may want to have a loop ahead of the read that waits until there are a certain number of bytes at the port before it reads the serial port.  You may want to put a loop around the serial port that waits until a valid number is read in before it exits the loop and goes to the numeric conversion.
    Message Edited by Ravens Fan on 08-09-2007 08:50 AM

  • Problem in reading a serial port

    Hi,
    I am working on a program about serial communication, my problem is when reading the response of the other serial port, my program always throws the "PortInUseException" and prints the error "Unknown Application". Yes, the port was use by that application but I want to read its response because I can already write to it.
    Any ideas would be much appreciated.
    Thanks!

    Try the "Serial Read with Timeout.vi" (in Serial Comm examples). Do remember to specifiy no. of bytes you are expecting from the Serial Port.
    ian.
    Ian F
    Since LabVIEW 5.1... 7.1.1... 2009, 2010
    依恩与LabVIEW
    LVVILIB.blogspot.com

  • Problems reading the serial port with labview 5.1.

    I open the example serial.vi , I select write to serial port, run the programm, I don`t have any problem. But when I select read serial port, I get the error code 16392and hex code error x4008. I need to know what can I do? Thanks a lot

    Any time you get an error in LV you can right click on the error cluster indicator and do a "Explain Error".
    If you do this for the error code you reported, the explanation says that it was a framing error.
    In serial communications, a framing error indicates that the hardware was not able to detect a start bit, data then the stop bits that comprise a frame.
    This prompts me to suggest that you check you port setting on the serial port. You want to make sure you are setting the port for the correct;
    Number of start/stop bits,
    Baud rate
    data bits
    parity (just for good measure)
    and hardware handshaking.
    I hope this helps,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Function for reading from serial port

    Hi experts,
    We are trying to read data from the serial port with the following function we got from internet.
    The problem is when creating the object with the sentence CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.
    This returns a sy-subrc = 2 and shows the exception NO_CREATE_OBJECT.
    We already copied the file MSCOMM32.OCX in c:\windows\system32 and we successfuly registered it, with regsvr32.exe.
    We tried it with Windows XP and Vista.
    Anybody has any idea?
    Thanks in advance
    FUNCTION ZSERIALCOM.
    ""Interfase local
    *"  IMPORTING
    *"     REFERENCE(MODE) TYPE  I DEFAULT 0
    *"     REFERENCE(COMMPORT) TYPE  I DEFAULT 1
    *"     REFERENCE(SETTINGS) TYPE  C DEFAULT '2400,N,8,1'
    *"     REFERENCE(OUTPUT) TYPE  C OPTIONAL
    *"  EXPORTING
    *"     REFERENCE(INPUT) TYPE  C
    *"  EXCEPTIONS
    *"      NO_CREATE_OBJECT
      TYPE-POOLS: sabc.
      INCLUDE ole2incl.
      PERFORM init.
      PERFORM open_port USING commport settings.
      IF mode = 0.
        PERFORM read_port
        CHANGING input.
      ENDIF.
      IF mode = 1.
        PERFORM write_port
        USING output
        CHANGING input.
      ENDIF.
      PERFORM final.
    ENDFUNCTION.
    DATA: o_obj TYPE ole2_object.
    *& Form Init
    text
    --> p1 text
    <-- p2 text
    FORM init.
    DATA:
    wa_repid LIKE sy-repid.
    wa_repid = sy-repid.
    CALL FUNCTION 'AUTHORITY_CHECK_OLE'
    EXPORTING
    program = wa_repid
    activity = sabc_act_call
    application = 'MSCOMMLib.MSComm.1'
    EXCEPTIONS
    no_authority = 1
    activity_unknown = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.
    IF sy-subrc <> 0.
    RAISE no_create_object.
    ENDIF.
    ENDFORM. " Init
    FORM open_port *
    --> COMMPORT *
    --> SETTINGS *
    FORM open_port USING commport settings.
    SET PROPERTY OF o_obj 'CommPort' = commport.
    SET PROPERTY OF o_obj 'Settings' = settings.
    SET PROPERTY OF o_obj 'InputLen' = 0.
    SET PROPERTY OF o_obj 'PortOpen' = 1.
    ENDFORM. "open_port
    FORM read_port *
    --> INPUT *
    FORM read_port
    CHANGING input.
    DATA:
    wa_buffer TYPE i.
    DO 10 TIMES.
    GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
    IF wa_buffer > 0.
    GET PROPERTY OF o_obj 'Input' = input.
    EXIT.
    ENDIF.
    ENDDO.
    ENDFORM. " read_port
    FORM write_port *
    --> OUTPUT *
    FORM write_port
    USING output
    CHANGING input.
    DATA:
    wa_buffer TYPE i.
    SET PROPERTY OF o_obj 'Output' = output.
    DO 10 TIMES.
    GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
    IF wa_buffer > 0.
    GET PROPERTY OF o_obj 'Input' = input.
    EXIT.
    ENDIF.
    ENDDO.
    ENDFORM.
    *& Form final
    text
    --> p1 text
    <-- p2 text
    FORM final.
    SET PROPERTY OF o_obj 'PortOpen' = 0.
    FREE OBJECT o_obj.
    ENDFORM. " finalbligw

    Hi ,
    I want to read value form weigh bridge through COMM port. I have developed the FM and done the setting as mentioned in the below link
    Read COMM port using ABAP w/o third party software 
    but while executing the FM independently I am able to get the value from the COMM port,but when I call the FM from a program I am not able to get the output value from the FM.I am calling the FM from the report program.please find the code below.
    report test.
    data : lv_input TYPE c.
    CALL FUNCTION 'ZFM_WEIGHINTERFACE'
      EXPORTING
        MODE                         = 0
        COMMPORT               = 1
        SETTINGS                  = '1200,N,8,1'
        OUTPUT                     = ''
      IMPORTING
        INPUT                        = lv_input
      EXCEPTIONS
        NO_CREATE_OBJECT       = 1
        OTHERS                 = 2
    IF SY-SUBRC <> 0.
    * Implement suitable error handling here
    ENDIF.
    if I execute the FM independently the output is getting perfectly.but while calling from a program i am facing the issue..
    any suggestion is appreciated.
    Thanks
    Vivek

  • Efficient optimized way to read from serial port and GPS data display using map

    Hi,
    I have a custom h/w which reads the data from GPS Rx and after parsing send it to PC over RS232.
    Each second it sends 201 bytes to PC. I have developed a VI to read the GPS data and display it. Project file is attached.
    Fulctionality of different loops are as following:
    1. LOOP 1: 1.1 Reads the serial data from com port.
                   1.2 Synclonize the frame using start bytes "a" and "z".
                   1.3 Reads next 4 bytes containg receiving error information.
                   1.4 Reads next 195 bytes. in which initial 80 byes are GPS data. rest are others.
    2. LOOP 2: 2.1 Extarcts the GPS information and put them in an array.
                      2.2 Extarcts the receive error infor and counts the total error by incrimenting the variable using shift reg.
    3. LOOP 3:3: 3.1 Displays the GPS data in chart and log the data in a file.
    4. FLOW : Uses the GMAP .NET based API to creat a MAP and display.
    Problem statement:
    1. Functionality acheived.
    2. However in between data set is being missed by the programm. 
    Quesitions:
    1. Is the developed VI is efficient in terms of using queue loacl variables etc.
    2. What are the improvments I can do to solve the problem.
    Any other suggestions|
    Thank you
    jayant
    jayant
    Attachments:
    Telemetry_Receiver_v2.zip ‏3075 KB

    One of the most common problems in serial communication is the need for an adequate timing: how much time is expected your device to spend before answering? Have you put and adequate pause in your code before reading from the serial port?
    Hope this helps
    Roberto
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Reading 2 serial port in a same time

    i want to monitor 2 type of data in a same time
     1- i have 6 sensor and i send them from micro avr and packed in this format >> 
    printf("%4d%4d%4d%4d%4d%2d@%4.2f\r\n",a,b,d,c,e,p,f);
    i want to recive all 30 data bytes  in one port then unpacked them...
    2- i have a gyro sensor that sends data very slow every 500ms thats data like this   >> 
    x+40.2\s\s\Y+42.3\r\n
    i want recive all 16 data byte in another port and send feed back (write serial) too.
    i recive gyro sensor data recive in fix 16 byte and dont have any problem  .
    but i have problem that i dont recive fix data from 30 data(from micro) its hangs or recive lower.
    its becuse i use 2port in same time if i use it alone there is no problem.i recive it fix.
    plz help me.
    also im sory im not good at english.
    Attachments:
    8-28-2012 8-07-41 PM.jpg ‏289 KB
    read and write in 2 serial port.vi ‏28 KB

    Hey,
    I would first add some error handling to your loops.  The way you have it setup, the loops could be running in error and you will never know about it.  The code I have attached will stop the loop if an error occurs.
    Does it throw any errors when you run it?
    Lewis Gear CLD
    Check out my LabVIEW UAV
    Attachments:
    read and write in 2 serial portv2.vi ‏28 KB

  • Plot more than one analog value to a waveform chart by reading from Serial Port

    I have 4 LDRs and I want to plot their values to a waveform chart by reading them from the serial port. I have looked around and found an example of a VI plotting one value to a waveform chart (attached below) but I am unsure about how to expand this for 4 different waveforms, mostly because I don't particularly understand the way is being read currently. If someone could either point me in the way of a relevant example or explain/show me a solution, or explain howthe current VI I have works, that would be greatly appreciated.
    Attachments:
    LDRread.vi ‏20 KB

    Since I assume each LDR (whatever that is) has its own serial connection, you will need to read from 4 different serial ports.  From there, just form an array of all the data and write to the chart.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions

  • Computer freezes while reading from serial port

    My computer freezes when i tried to read from a serial port for a longer period of time such as 10 hours. I always close the serial port after reading. please, help me solve this problem

    I too experienced a similar problem twice on my machine and I have no idea how to stop it because it is so intermittent and I cannot replicate it.
    Perhaps I can offer some clues.
    The Labview screen cannot be stopped and some parts of Windows appears frozen. Oddly enough I can switch to the block diagram but thats about all I can do. The LV stop button will indicate a mouse click on it but the VI does not stop. iT also cannot be closed.
    Even the reset button and power button on the PC does not work. I am forced to power down the PC (pull the plug) to get back control.
    I believe it is related to a visa call to my serial Balance.
    ANyway no solution but hopefully some clues.
    Dell Optiplex GX260 w/ 500MB RAM
    Win2K 500.2195 w service pak 4,
    NI
    serial Hardware and NI serial ver1.45 (16 com ports)
    Labview 6.1 and 7

  • K8NGM2-FID Serial Port problem

    The K8NGM2-FID has a serial connector, to which I attached a port so that I hook it up to a Polar heart rate monitor transmitter (Interface Plus unit with wire to serial port).  I never noticed, but assumed it was COM1.  In any case, it was transmitting fine as needed, then literally one night to the next morning it wouldn't anymore.  That's the problem.  This is my home computer and there were no other people or changes, and the watch's battery is ok (checked with a backup).  Looking at COM1, Device Manager (XP) says it's working, but the Polar software (PPP 2.1) says "Port Not Found" and chooses COM3 ("get status").  In Belarc, under Printers it shows COM1 being used by Amyuni Document Converter 2.51.  I've long had two of its affiliated programs installed, PDFWriter and PDFill Editor & Tools - document conversion is part of the latter, tho I've never used it - but would that interfere with a hardware connection?  Just to test, I uninstalled PDFill Editor/Tools, but Belarc still shows the Doc Converter on COM1. 
    So, if I haven't lost you, this is to say I am.  I did unplug/replug the transmitter connection to the serial port.  Other than the Polar unit going bad (think it's passive), the only other thing I can think of is the COM plug on the board went bad, but that's hard to believe (would it effect the COM port reading in Device Mgr?)  Any other ideas?  Thanks.

    Quote from: Russ_xp on 24-May-07, 16:41:24
    I think you are on the right track - seems that your PDF software has taken over COM1 and it is now assigned to a software Printer device. You could try to remove this or go into Device Manager and open the properties of the COM Port and change it to COM3 (just go through all the Advanced Options).
    I did remove the PDF software, moved what remained of the folder to another drive, and ran two registry cleaners and restarted, but Belarc still shows COM1 held by Amyuni Document Converter 2.51.  Turning to plan B, in Device Manager>Properties, what would need to be changed to make it COM3?

  • How can I read a serial port using XCode?

    Hello,
    I'm using an iMac 2009 with Mac OS X 10.6.7. I have a USB to Serial cable and I want to connect a hardware I made using a microprocessor Microchip PIC to my mac. I'd like to read values from the serial port and also write values to it. I'm already able to do this using the Terminal with the following command:
    screen /dev/tty.usbserial 9600
    I'd like to build my own application now. Does anyone could send me any sample code?
    I'm using XCode 3.2.5 and I'm a beginner on XCode.

    I looked at Dev Center for sample code, and I found this link:
    http://developer.apple.com/library/mac/#samplecode/SerialPortSample/Introduction /Intro.html%23//apple_ref/doc/uid/DTS10000454-Intro-DontLinkElementID_2
    I downloaded the sample Xcode project and, when I click on "Build and Run" button, it generates an error with the following message:
    "GCC 4.2 is not compatible with the Mac OS X 10.4 SDK (file SerialPortSample.c)"
    Maybe, it occurs because the code is too old (2005). I didn't find any newer sample.
    Could you help me?
    Thank you.

  • Controlled reading from serial port

    I'm trying to establish a connection to an external device through the serial port. This is done in a while-loop which sends an association request tries to get a response if a response is not recieved a new rewuest is sent, etc. At the moment this procedure does not work. I am considering two explanations for this. The first is that the loop does not wait long enough for a response to come and simply keeps pumping out requests, the other is that there is something wrong with the reading algorithm, that doesn't let it properly take in information from the serial port.
    Solved!
    Go to Solution.
    Attachments:
    association_loop.GIF ‏5 KB
    read_visa.GIF ‏8 KB

    I made a new version of the read case. The old version was a while loop, the new version is a while loop which will go on until it encounters an EOF character. In this case it is
    0xC1 or 'Á'. I thought the old version would break before getting any message. This doesnt get any signal either. I have probed it, and it doesn't get a string from which to take the length.
    Attachments:
    read_visa2.GIF ‏10 KB

  • Serial port problems/explanation on the pda

    Hello,
    I have attached the jpg for a simple test I had carried out. I am writing a custom command to an external hardware and waiting for a response from the hardware.
    As you may see in the block diagram, I am waiting for a response from the external hardware in the 4th frame. In the 5th frame I calculate the waiting time. The 4th frame also informs us that there is data in the serial port that has to be read. Yet I need to introduce an empirical delay (405 ms) befoer I can read the data. Does anyone have an explanation/theory why I need to add this delay while switching from Write to Read in the PDA ?
    Similarly, I introduced a Case structure inside the WHILE loop of the 4th frame that was driven by the current lo
    gic. Inside the TRUE case I inserted the 7th frame logic. This did not work either. Any explanations?
    And lastly I ran this program multiple times at different time delays. If I reduced the time delay sufficiently, then after a few runs (approx 3-5), the program hangs. I am closing the serial port though it does not appear in the current diagram . Am I doing something wrong with the serial port handling ?
    Thanks for all the help that you can provide. I am open to any explanation that you may have regarding WinCE/PocketPC etc.
    Attachments:
    testing_read_write_serial.JPG ‏102 KB

    The answer can be found by asking and/or searching archives at www.ibutton.com/TINI

  • Reading from serial port

    HI,
    I need to read data from virtual serial (rfcomm - BT GPS receiver). I connect to my gps using system command:
    [root@localhost ~]# rfcomm connect /dev/rfcomm0 XX:XX:XX:XX:XX:XX
    and this creates port at /dev/rfcomm0, when I do :
    [root@localhost ~]# cat /dev/rfcomm0
    I get:
    M,0.0,0000*76
    $GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05
    $GPRMC,000009.999,V,0000.0000,N,00000.0000,E,,,101102,,*17
    $GPGGA,000010.999,0000.0000,N,00000.0000,E,0,00,50.0,0.0,M,0.0,M,0.0,0000*7E
    $GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05
    and the only problem is what to do to read this sequences via java application. I obtained package comm2.0.3.zip , but have no idea what next. I would be grateful for any help.
    best regards
    joshua

    I did everything described here:
    http://www.geeksville.com/~kevinh/linuxcomm.html
    got an example from:
    http://java.sun.com/developer/releases/javacomm/SimpleRead.java
    (the defaultPort = "/dev/term/a"
    replaced with
    defaultPort = "/dev/rfcomm0")
    i connect to my gps with:
    [root@localhost ~]# rfcomm connect /dev/rfcomm0 XX:XX:XX:XX:XX:XX
    start the application and get an error:
    java.io.IOException: Error instantiating class gnu.io.RXTXCommDriver
    gnu.io.RXTXCommDriver cannot be cast to javax.comm.CommDriver
    at javax.comm.CommPortIdentifier.loadDriver(CommPortIdentifier.java:239)
    at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
    at comm.SimpleRead.main(SimpleRead.java:78)
    Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.comm.SunrayInfo.isSessionActive()Z
    at com.sun.comm.SunrayInfo.isSessionActive(Native Method)
    at com.sun.comm.Portmapping.registerCommPorts(Portmapping.java:155)
    at com.sun.comm.Portmapping.refreshPortDatabase(Portmapping.java:100)
    at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:138)
    at comm.SimpleRead.main(SimpleRead.java:78)
    Java Result: 1
    i think i did everything about rxtx as described. could anyone help?
    best regards
    joshua

  • How can I autoindexi​ng data from vi that read the serial port (CODE)

    Hello. I´m working in a proyect in the company, the proyect consist in read two incremental encoders for the inspection of automotors supension. I have a Digital Read Out System that read the 2 linear encoders, the DRO it has a serial RS-232 interface, i can read the data from the DRO to my computer, but now, I want to storage the information in Arrays (for autoindexing) for then make a graphic, If you want check the program, and if you tell me information, or a example code  thanks for yor help.
    P.D. Only if the data is diferent is sotraged. (I have LabVIEW 5.1.1)
    Atn. Ing. Jorge Cardozo. San Luis Rassini Corporation. Piedras Negras Coahuila Mexico.
    Thank you for your help.
    Attachments:
    KA-COUNTER (Comparacion).vi ‏77 KB

    hi there
    to collect scalar data in an array you can use a so called "Shift register". To display the history of scalar data you can use a Waveform Chart (not a "Graph", a "Chart"). See attachments. because i can't save the vi as 5.1 i appended some screenshots of the front panel and the block diagramm.
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"
    Attachments:
    KA_Counter_BD.JPG ‏122 KB
    KA_Counter_FP.JPG ‏86 KB

Maybe you are looking for