gettingstarted
[Top] [All Lists]

Re: Serial Port Problems

To: "Getting Started" <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Serial Port Problems
From: "Aaron Ballman" <aaron at realsoftware dot com>
Date: Mon, 30 Aug 2004 20:42:24 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <7FD09879-FAEE-11D8-BF49-000A95B8E76E at bellsouth dot net>
> ReadPort: Action
> dim ChatsworthPort as Integer
> dim POpen as Boolean
> ChatsworthPort = systemInfo 'Find Chatsworth Reader
> Serial1.port = ChatsworthPort 'Set Port Number

First off, .Port is really a mostly deprecated property.  You should always
use .SerialPort, like this:

Serial1.SerialPort = System.SerialPort( 0 )

(Pass in whatever the serial port index is.  You can count them with
System.SerialPortCount).

> POpen = Serial1.Open

I'm assuming it opens fine, but I noticed that you have no setup code.  You
never seem to set the baud, stop bits, etc.  Perhaps that's the issue?

>   Sub DataAvailable
> dim SerialData as string
> SerialData = Serial1.ReadAll(Encodings.WindowsANSI)

Are you sure the data coming from the device is WindowsANSI?  That's a
really strange encoding to get from a device.  More often than not, it's
either ASCII or nothing.

> serial1.close

You close after a single read?  I thought you wanted multiple pieces of
data?

I would try using .SerialPort and making sure the setup information is
correct.  Or perhaps some more information on what's going wrong.  In terms
of why feeding the form then opening the port isn't working, it's because
the serial device won't buffer incoming data if it's not been opened.  So
you're giving the serial port data, then opening it, then asking what data
is there, which it reports as being no data.

HTH!

~Aaron

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>