Serial Port Communication


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Serial Port Communication

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Posts
    28

    Serial Port Communication

    everyone (I'm new to the forum)

    I've written a program to retreive data from a badge system via serial port.
    The problem is that the data I receive is in some sort of code, I believe it is ANSI but I'm not sure.

    Here's the input I get:

    ]&DU

    Normally this code must contain at least the following (human readable):
    28633 (this is the id of my badge)

    Here's my code for input:

    -------------------------------------------------------------------------
    StringBuffer inputBuffer = new StringBuffer();
    int newData = 0;

    while (input.available() > 0)
    {
    newData = input.read();

    if (newData == -1)
    {
    break;
    }

    if ('\r' == (char)newData)
    {
    inputBuffer.append('\n');
    }

    else
    {
    inputBuffer.append((char)newData);
    }

    System.out.println(new String(inputBuffer));

    -------------------------------------------------------------------------

    Does anyone know how I can handle this?

    thx in advance

  2. #2
    Join Date
    Mar 2006
    Posts
    28
    OK the input I got was wrong and I managed to receive an other input:

    Code:
     oJ/Dx#
    this one should be correct, I got it when I entered the building with my badge
    Also I forgot to mention that I'm using JavaComm for serial communication

  3. #3
    Join Date
    Mar 2004
    Posts
    635
    Take each character and spit out its ascii value.
    I believe you can just cast each character to a byte.

  4. #4
    Join Date
    May 2005
    Location
    Ontario, Canada
    Posts
    173
    Please if you got it working let me know. I need it.

Similar Threads

  1. Replies: 1
    Last Post: 02-21-2006, 02:23 AM
  2. Serial Port Programming
    By newbie29 in forum Java
    Replies: 0
    Last Post: 05-16-2005, 05:55 PM
  3. Com port Serial Communication.
    By John O. in forum .NET
    Replies: 2
    Last Post: 01-14-2002, 01:37 PM
  4. Com port Serial Communication.
    By John O. in forum .NET
    Replies: 0
    Last Post: 01-14-2002, 12:59 PM
  5. Com port Serial Communication.
    By John O. in forum .NET
    Replies: 0
    Last Post: 01-14-2002, 07:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center