URGENT: Capturing data through serial port

Hi,
My problem is with the use of javax.comm API. I have an RFID tag reader connected to
the serial port. It is a handheld reader and reads tags when its trigger is pulled. The
data that is read is sent to the serial port. This is what I want to capture.
I tried to test the reading operation by running the SimpleRead sample. What I see is
that I pull the trigger once to read 1 tag, but that generates 3 DATA_AVAILABLE events.
The tag ID that is read is 16 bytes, preceded by a 3 byte AIM Identifier (that declares
the following data was read from an RFID tag, and not a barcode which has different
AIM Identifiers for the different symbologies - but I digress.) By inserting some println's,
I was able to see that the 19 bytes of data are read 8 bytes at a time. The first 8 bytes
are read on the first DATA_AVAILABLE event, the next 8 are read on the second event
and the last 3 bytes are read on the 3rd DATA_AVAILABLE event.
This is strange & not good for me. How can my application know that the data read in
these 3 separate DATA_AVAILABLE events is to be concatenated to form a single
tag ID? Why is the single trigger-pull & tag read operation broken up into chunks of
8 bytes? Is there some configuration setting that will give me the behavior I want?
(I cannot rely on the length of the tag ID being 16 bytes always, because the same
reader will also be reading barcodes where the data may have varying length)
Thanks for any help. This is really urgent.
- Ajoy

please use the [ code ]and [code ] tags for code.
I don't think you have a problem with the code, it's more like understanding how to make it work.
to make the read method return.You do not have a read() method.
The code is behaving as it should.
You need to use the SimpleRead class as a thread, add and remove the Serial port listener as needed.
You read all data available, then send it to a method to parse the buffer.
You can count how much data was read so you know how much to parse.
I never used receive threshhold.
Here is example (sample)of my serial port reader
//SerialIO
   public void serialEvent(SerialPortEvent event) {
        switch(event.getEventType()) {
              case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
            break;
        case SerialPortEvent.DATA_AVAILABLE:
            this.dataManager.readData();
//DataManager
public void readData() {
     String str;
     int     bytes = 0;
     long endTime, now;
     try {
          while (this.owner.isComPortOpen
               && (SerialIO.inStream.available() > 0)) {
               bytes = SerilIO.inStream.read(this.buffer);
               if (bytes > 0) {
               if (bytes > this.buffer.length) {
                    System.out.println( ": Input buffer overflow!");
     **Here is where you parse your buffer
               sendDataToParser(bytes, buffer);
          } catch (IOException ex) {
               System.out.println( ": Cannot read input stream");
      * Stops the serialEvent listener
     protected void stopSerialEvent() {
          SerialIO.serialPort.removeEventListener();
          try {
               Thread.sleep(2000);
               flushInputStream();
          } catch (InterruptedException e1) {
               // TODO Auto-generated catch block
               e1.printStackTrace();
      * Starts the Serial event listener
     protected void startSerialEvent() {
          // TODO Auto-generated method stub
          try {
               SerialIO.serialPort.addEventListener(SerialIO);
          } catch (TooManyListenersException e) {
               // TODO Auto-generated catch block
               //System.out.println("startSerialEvent in dataManager");
               e.printStackTrace();

Similar Messages

  • Unable to capture data from Serial port using LVRT2010 in single core pentium 4 machine

    I am using application written in Labview using windows Labview
    Runtime environment 2010. Application creates a tunnel to intercept data from
    Serial port.
    My problem is, Currently, I am using single core Pentium
    processor. When I am trying to intercept the data between COM1 and COM7 (COM 7
    is a virtual port) it is not able to capture data.
    When I am running Labview RT environment using dual core
    processor machine it is running normally. I wonder whether it could be the compatibility issues with
    single core Pentium processor.

    Hi Magnetica
    Are both of the machines running the same runtime engine,
    drivers ect?
    Have you had RT applications running on this
    machine before?
    Is the development computer a 64bit machine?
    The processor is a supported model (See link below).
    http://zone.ni.com/devzone/cda/tut/p/id/8239
    Regards
    Robert
    National Instruments UK & Ireland

  • Send DAQ measurement results through serial ports

    Hi, All
    I use PCI-6034E for measurement. After DAQ gets data, I send them to another computer through serial port (com1). I write a Virtual C++ program, which calls NI-DAQ library functions to implement DAQ data sampling (multiple channel scan) and sends measurement data to another computer through serial port under request. DAQ data sampling and serial communication are implemented in two threads. They are running concurrently. They share a global memory for measurement data. The serial communication thread will do infinite wait and send data only when another computer sends a request through serial port.
    I met two problems. First, when I reduce the size of DAQ measurement buffers (piBuffer and halfpiBuffer, I us
    edouble buffer model), DAQ measurement is often interrupted by the message "[DAQ_DB_HalfReady] returned NI-DAQ warning 10846. Your application was unable to retrive data from the background acquisition buffer fast enough so the unretrieved data was overwritten with new data. ...". I want to get run time data so I need to reduce the buffers as small as possible. How can I solve it ? The second problem is that the serial port gets error data (nothing) from measurement computer sometimes, especially when DAQ initializes itself and finishes work. It looks like that there is a conflict between DAQ and serial port. Does anyone have similar experience about this? Any suggestion?
    Thank you in advance.
    Le Cai

    Le Cai,
    You are correct that the number of scans to read is equal to half of the buffer in double buffer mode. I was mistaken and referring to a standard (non double buffered) operation. However, you can increase the size of your buffer without affecting the period of your acquisition. A buffer of 60 is quite small and, as such, will be more prone to overflow errors. The rate is actually set through the DAQ_Rate() and DAQ_Start() functions. For more information on these functions and how to configure the scan rate, please see the NI-DAQ Function Reference Manual.
    NI-DAQ Function Reference Manual for PC Compatibles
    http://digital.ni.com/manuals.nsf/websearch/1630A0B68738B269862567C1007A2912?OpenDocument&node=132100_US
    A good place to start would be the example titled, "DAQdoubleBuf.c" which ships with the NI-DAQ driver. If you installed the examples for Visual C++ when you installed the NI-DAQ driver you should be able to find this example in the \Program Files\National Instruments\NI-DAQ\Examples\VisualC\AI folder on your computer. This example would be a good template as it is very close to what you are trying to do.
    If you observe that you only receive the overflow error when you are operating the two threads, thus ruling out the buffer size as being a potential problem, you may want to examine whether or not your second thread is placing a lengthy exclusion on your data buffer during the period when your first thread is trying to move the data. If your first thread has to wait during the half-buffer transfer this could easily cause the overflow, as the acquisition would be running but the transfer would be paused. Instead of placing a mutual exclusion around one piece of global memory you could try using a queue instead. A queue approach will allow you to pass the data from the first thread into a queue to be read, when convenient, by the second thread. In this method the first thread would never have to wait as the transfer would just be a handoff.
    Regards,
    Justin Britten
    Applications Engineer
    National Instruments

  • How to save a datas from serial port?

    How to save a datas from serial port?

    Hi
    I need some help about rs-232 communication. I want to make a vi witch can do this things:
    -read a txt file (to simulate a serial port like when the datas are coming)
    i will get 3 different data in serial port (like this: 121 213 135)
    i want to save in a txt file what datas get my vi
    so
    -write in a txt file or draw in a diagram (or both)
    so my problem is: read in serial port and save in a file and draw a diagram.
    if anybody can help pls HELP ME because im a beginner in this problem.
    I already do something but Im not sure that good.
    Thx for all.

  • Write data to serial port every two minutes

    Hi,
       I use VISA-Write to write data to serial port. I want to write a byte every two minutes. What should I do?
      Thanks!

    hengfo,
    that question is not connected to LV nor to VISA. Its more a systematic question....
    So let's view at this a bit more abstract:
    You want to "toogle" between two different messages sent to your interface. So you have to know:
    - What was the last state i sent?
    - When do i have top send the new state?
    Even more abstract:
    - How can i switch between the states?
    Since the states are known before your program is executed, you can insert them into an array. Next, you have to read out the appropriate index from the array which contains your new state. Send the state and go to the next state. Propably you want to change timing, but that's easy too.
    See attached screenshot for a possible solution:
    hope this helps,
    NorbertMessage Edited by Norbert B on 09-11-2007 07:57 AM
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.
    Attachments:
    StateSwitching.PNG ‏8 KB

  • I want to capture data through I/O while posting to Customer Line items

    Hi Experts
    Can you please suggest me that while posting to Customer line items i would require to capture data through Internal Order, is this possible if yes please explain
    Regards
    Sreenivasulu

    Hi
    Internal Order details can be updated to the P&L line item ie revenue line item in your case. From ECC 6.0 it will be available in the General Ledger view of the document.
    Regards,
    Lakshmanan Krishnan

  • Want to capture data through I/O while posting to Customer Line items

    Hi Experts
    Can you please suggest me that while posting to Customer line items i would require to capture data through Internal Order, is this possible if yes please explain
    Regards
    Sreenivasulu

    If you are classic GL, this not a standard functionality.
    If you are new GL, you can have profit center on customer / vendor line items.
    Also activate document splitting.
    Regards,
    Ravi

  • How send data to serial port from forms 6i

    How send data to serial port to activate hardware connect.
    The hardware is a drawer for cash the point of sales.

    Andres,
    I do the exact thing you are looking for,
    I spool out a text file using text_io
    the file will either contain a double ^G or an epson escape sequence, depending on the drawer type connected.
    I then copy this file to the port using a copy function id d2kwutil
    Works perfectly, but god knows how I'll do it if we want to run the point of sale over the web :)
    John

  • File transfer of larger size through serial port

    Hi
    I need to transfer files of larger size may be around 20Kb through serial port. Can some one suggest some idea or can provide any sample VI for achieving this. i guess we cannot send the complete file at a stretch, so we may need to form some packets and then send. If i am right i need some help for achieving this.
    Padhu

    You may want to use something like the XMODEM protocol. 
    I believe you can find a version of XMODEM that can be used with an NI-VISA session located here on the OpenG forums.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • LV acquire the print information from the embed board with Linux system through serial port

    I want to acquire the print information by LV from the embed board with Linux system through serial port, like the window hyperterminal tool?
    I try to use VISA serial config function to achieve it ,but lost and prompt that is error like attachment.
    I can't sure that my idea is reasonable.
    help me
    thanks a lot!

    I ended up finding the answer to my problem. After pointing a client directly at one of the DPS systems, I saw the following error in the logs:
    [27/Jul/2009:17:11:47 -0400] - OPERATION  - INFO  - conn=3688 op=4 BIND RESPONSE err=12 msg="The server is not configured to pass through control 1.3.6.1.4.1.42.2.27.8.5.1" etime=0After adding that control OID to the allowed-ldap-controls, I could login via password auth. Adding this control also allowed for password changes to work from a client system.

  • Problem while reading data from Serial Port

    Hi All,
    I am facing some problem while reading data from Serial Port.
    As per the requirement I am writing the data on Serial Port and waiting for response of that data.
    Notification for data availabilty is checked with method public void serialEvent(SerialPortEvent event) of javax.comm.SerialPortEventListener.
    When we are writing data on the port one thread i.e. "main" thread is generated and when data availability event occures another thread "Win32SerialPort Notification thread" is generated. This creates problem for me as we can't control thread processing.
    So can anybody pls explain me how to overcome this problem?
    Regards,
    Neha

    My Problem is:-
    I am simoultaneouly wrting data on port & reading data from port.
    First I write data on port using outputStream.write() method. Now when target side sends me response back for the request on serial port DATA_AVAILABLE of SerialPortEventListner event occured,we are reading data from serial port.Now till the time we didn't get the response from target next command can't be written on the serial port. When we are writing data on port main thread is executed.Now my problem starts when DATA_AVAILABLE event occured.At this point another thread is created.Due to this my program writes data of next command without reading response of previous command.To solve this prob. I have used wait() & notify() methods as follows.But again due to this my pc hangs after execution of 2 commands. (PC hang in while loop in a code provided below.)
    From SOPs I could figure it out that after 2 commands we are not able to write data on serial port so DATA_AVAILABLE event doesn't occure n pro. goes in wait state.
    Can anybody help me to solve this issue.
    Neha.
    Code:
    public void serialEvent(SerialPortEvent event)
              switch (event.getEventType())
                   case SerialPortEvent.BI:
                   case SerialPortEvent.OE:
                   case SerialPortEvent.FE:
                   case SerialPortEvent.PE:
                   case SerialPortEvent.CD:
                   case SerialPortEvent.CTS:
                   case SerialPortEvent.DSR:
                   case SerialPortEvent.RI:
                   case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                                 break;
                   case SerialPortEvent.DATA_AVAILABLE:
                        try
                             dataThread = Thread.currentThread();
                             dataThread.setPriority(10);
                             dataAvailable = true;
                                                                                    byte[] tempArray=new byte[availableBytes];
                                        inputStream.read(tempArray);
                                                                       catch (IOException io)
                             SOP(io, "Error in serialEvent callback call for event DATA_AVAILABLE");
    public void  writetoPort(byte[] data) throws IOException
                             outputStream.write(data);
                              while(finalTimeOut >= actualTime)
                            if( ! dataAvailable)
                                    actualTime = System.currentTimeMillis();
                           else
              synchronized (mainThread)
                   mainThread = Thread.currentThread();
                   mainThread.wait();
    public  void sendDatatoUser(byte[] b) throws Exception, HWCCSystemFailure
              obj.returnData(b);
              synchronized(mainThread)
                   mainThread.notify();
                                                           

  • Read data from serial port or TCP port of frontend PC

    Hello Friends,
    I have requirement to read data from device connected to frontend PC which will provide meter reading data.
    Vendor has given me two option.
    1. Device can be connected to seiral port and data transfer will be done through MODBUS RTU protocol.In that case data need to capture from serial port.
    2. Device can be connected to TCP port and Socket program can be provided for data transfer. In that case SAP will act as client and communicate with TCP port.
    There will be multiple workstation with individual meters connected to them.
    I am aware of text file interfacing through front end tools using custom code using VB,JAVA or others.
    Is there any solution availble  to achieve above things using  ABAP other than text file , like direct communication?
    I am using ECC 6.0.

    Hello,
    Socket programming in not available on ABAP, but you may use RFC for the same.
    Use the below links for more details
    [Link 1|http://help.sap.com/printdocu/core/print46c/en/data/pdf/BCFESDE2/BCFESDE2.pdf]
    [Link 2|http://forums.sdn.sap.com/thread.jspa?threadID=1820233]
    Regards,
    Abhishek

  • Help with reading information coming from a software into LabVIEW through Serial port

    Hi,
    I am new to LabVIEW and also an amateur in using RS232 for communication. I have this software that has these icons like speed increase/decrease, elevation up/down, start/stop. Now, when I click these buttons on the software, they perform the appropriate functions. For example, if I press start button, the signal must go through a serial COM port into LabVIEW to start the machine. How do I do that? How do I find what format the code word is when I press a button on the software? And how to decode the information to read whether the button pushed is start etc...? Any help would be appreciated.

    I may not be perfect, but I'm all I got!

    That information would be in the programming manual for the device you're controlling. Unless you have a device that has no documentation or you cannot get the documentation that's the first place you should look. If you cannot get the documentation at all then you've got some reverse-engineering to do. To do this you will either need a serial port sniffer (a hardware device), or you can try to use a software-based port capturing program. On Windows PortMon is the most prevalent. This will show you how the port was configured (baud rate, stop bits, etc). Warning: the information is technical.
    As far as how to get it running in LabVIEW, you should take a look at the serial port communication examples that ship with LabVIEW. The most problems occur in figuring out how to (a) terminate a write command, and (b) determining when to stop reading. For (a) this is typically done by appending a carriage return or linefeed to the command. This is device dependent. For (b) this is usually done by the byte stream ending with a character like a linefeed. Again, this is device-dependent. 
    You may also want to peruse this KB article: Serial Instrument Control Tutorial. There are also lots of tutorial on the internet for basic tutorials on serial port communication.

  • Parsing data from Serial Port one byte at a time

    Hi everyone,
            What I want to do is read in from the serial port byte by byte and parse each byte that I am reading in. The size of the data read in varies. How do I do that? I can do using .dll but I want to learn how to do it in labview. I searched through the forum for something similar but no luck. I have seen some that puts the VISA read in a while loop and others that puts the property node,  "bytes at Port" in a while loop. What is the difference in doing either way? I am using Labview 7.1 Can anyone point me in the right direction?
    Thanks

    Hi guys..
    I'm still a beginner in using labview tcp/ip function. for now, i have a project to read the labview data with java programming language so that i can monitor that data using any devices that using java, such as PC or cell phone. my task for now is to determine the format of data that being sent (its type, length, etc), coz as far as i done until now, the data that read in the java is still a raw material so that i dont know how to gain the information from that data.
    my question is :
    - how does the type cast work in changing the data format from one to another?
    - how does the bytes to read in tcp read work? coz when i'm changing the length of bytes to read constant from 4 bytes to another, the data is becoming mess up. As far as i know, the bytes to read only read the first "constant number" byte in the tcp read to determine the length and type of the data..
    thanks

  • Error while trying to read more number of data via Serial port

    Hi All,
    I'm newbie to Serial Port programming. I'm trying to read data from dos based system which is sending 150 characters (including) at a time. That time my programm was fine but now they increased the length of the characters 300, now my programming couldn't read data. I'm using byte array to capture the data byte buff = new byte[3048*3048]Ypur reply would greatly appreciate.

    You have a byte array with more than 9 million bytes. What does that have to do with reading 300 characters?

Maybe you are looking for