DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  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:
    ƒ€ oÙJÙ/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, 01:23 AM
  2. Serial Port Programming
    By newbie29 in forum Java
    Replies: 0
    Last Post: 05-16-2005, 04:55 PM
  3. Com port Serial Communication.
    By John O. in forum .NET
    Replies: 2
    Last Post: 01-14-2002, 12:37 PM
  4. Com port Serial Communication.
    By John O. in forum .NET
    Replies: 0
    Last Post: 01-14-2002, 11:59 AM
  5. Com port Serial Communication.
    By John O. in forum .NET
    Replies: 0
    Last Post: 01-14-2002, 06:57 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links