Xojo Conferences
MBSOct2019CologneDE

Serial Stuff... (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Please add alias record functionality to RB
Next thread: About RB SQL support


Re: REALdatabase, collected wisdom   -   Seth Willits
  Serial Stuff...   -   Stéphane Pinel <
   Re: Serial Stuff...   -   Frank Bitterlich
    Re: Serial Stuff...   -   Stéphane Pinel <
     Re: Serial Stuff...   -   Frank Bitterlich
      Re: Serial Stuff...   -   Stéphane Pinel <
       Re: Serial Stuff...   -   Frank Bitterlich
        Re: Serial Stuff...   -   Stéphane Pinel <
       Re: Serial Stuff (Solved)   -   Stéphane Pinel <

Serial Stuff...
Date: 28.08.02 10:06 (Wed, 28 Aug 2002 11:06:34 +0200)
From: Stéphane Pinel <
I have to use (for the first time) Serial and I'm pretty confused:

- Is there a good tutorial regarding Serial/SerialPort ?

I need to read, from a ProCap badge reader, information that is read by the
reader from a PDF (sort of barcode). Information is transmited using serial
connection.

I'm on MacOS X 10.2, with a serial adapter KeySpan 19.

Normally, when a badge is read, information is sent to the port and my
application need to be able to react each time a badge in read.

So I would like to know how is the best way to handle this process ?

Thanks.

Re: Serial Stuff...
Date: 28.08.02 13:02 (Wed, 28 Aug 2002 14:02:47 +0200)
From: Frank Bitterlich
Nothing too difficult to do.

At app startup, set the Serial properties (which port, baud rate, etc),
and open the port.
Then in the DataAvailable event just read everything, add it to a
buffer, and pass that buffer to a pocedure that checks if a complete
"message" is in the buffer, snips that message,, and processes it.

The more complicated part is to know and understand the data format that
is sent from your hardware.

Cheers,
Frank+++

Stéphane Pinel wrote:
>
> I have to use (for the first time) Serial and I'm pretty confused:
>
> - Is there a good tutorial regarding Serial/SerialPort ?
>
> I need to read, from a ProCap badge reader, information that is read by the
> reader from a PDF (sort of barcode). Information is transmited using serial
> connection.
>
> I'm on MacOS X 10.2, with a serial adapter KeySpan 19.
>
> Normally, when a badge is read, information is sent to the port and my
> application need to be able to react each time a badge in read.
>
> So I would like to know how is the best way to handle this process ?

-

Re: Serial Stuff...
Date: 28.08.02 13:24 (Wed, 28 Aug 2002 14:24:48 +0200)
From: Stéphane Pinel <
Le 28/08/02 14:02, « Frank Bitterlich » <<email address removed>> a écrit :

> Nothing too difficult to do.
>
> At app startup, set the Serial properties (which port, baud rate, etc),
> and open the port.
> Then in the DataAvailable event just read everything, add it to a
> buffer, and pass that buffer to a pocedure that checks if a complete
> "message" is in the buffer, snips that message,, and processes it.

I did that without any problem using Serial Control dragged on a window. It
runs perfectly.

Now I'm trying not using Serial as a control in a Window, since my app need
to be ready for communication at launch time and all the time the app is
running.

So I declared a myReader object As Serial, then set all the properties
needed, but the IDE crash when I attempt to open serial (myReader.Open)...I
suppose I make a mistake but can figure out where...?

>
> The more complicated part is to know and understand the data format that
> is sent from your hardware.

I have the specs of the pdf sent by the hardware: no problem on this side.

Thanks.

--
St

Re: Serial Stuff...
Date: 28.08.02 13:38 (Wed, 28 Aug 2002 14:38:24 +0200)
From: Frank Bitterlich
The problem is that you need to put code into the event handlers, namely
DataAvailaable. To do this, you need to make a subclass of Serial first
(make a "New Class", and set it's parent to "Serial"), and instantiate
that subclass. The code goes into the DataAvailable handler of the subclass.

Cheers,
Frank+++

Stéphane Pinel wrote:
...
> I did that without any problem using Serial Control dragged on a window. It
> runs perfectly.
>
> Now I'm trying not using Serial as a control in a Window, since my app need
> to be ready for communication at launch time and all the time the app is
> running.
>
> So I declared a myReader object As Serial, then set all the properties
> needed, but the IDE crash when I attempt to open serial (myReader.Open)...I
> suppose I make a mistake but can figure out where...?

-

Re: Serial Stuff...
Date: 28.08.02 14:21 (Wed, 28 Aug 2002 15:21:59 +0200)
From: Stéphane Pinel <
Le 28/08/02 14:38, « Frank Bitterlich » <<email address removed>> a écrit :

> The problem is that you need to put code into the event handlers, namely
> DataAvailaable. To do this, you need to make a subclass of Serial first
> (make a "New Class", and set it's parent to "Serial"), and instantiate
> that subclass. The code goes into the DataAvailable handler of the subclass.
>

Following your advices, I've created a class cSerialReader and set is
superclass to 'Serial'. Then I've instantiated the subclass as:

------------
MySerialReader = New cSerialReader

mySerialReader.Port = 0
mySerialReader.Baud = 8
mySerialReader.Bits = 3
mySerialReader.Stop = 0
mySerialReader.Parity = 0

if Not mySerialReader.Open Then
msgBox "Ouverture série impossible"
End if
------------

...and the IDE crash at : mySerialReader.Open...

I saw that Serial has an other property: serialPort, I don't know if it is
needed but in debug mode this property appears to be NIL. Maybe it's the
cause of my crash ? How can I set up this property ?

Thanks a lot !

--
Sté

Re: Serial Stuff...
Date: 28.08.02 14:41 (Wed, 28 Aug 2002 15:41:38 +0200)
From: Frank Bitterlich
How does the IDE crash? Do you get a console crashlog? If so, you should
send it to RS with a REALbugs report.

It might indeed be necessary to set the SerialPort property. I haven't
used it yet, but IIRC you must use something like
"mySerialReader.SerialPort = System.SerialPort(n)", where n is in
[0..System.SerialPortCount-1]. But in any case it shouldn't cause a crash.

Cheers,
Frank+++

Stéphane Pinel wrote:
>
> Le 28/08/02 14:38, « Frank Bitterlich » <<email address removed>> a écrit :
>
> > The problem is that you need to put code into the event handlers, namely
> > DataAvailaable. To do this, you need to make a subclass of Serial first
> > (make a "New Class", and set it's parent to "Serial"), and instantiate
> > that subclass. The code goes into the DataAvailable handler of the subclass.
> >
>
> Following your advices, I've created a class cSerialReader and set is
> superclass to 'Serial'. Then I've instantiated the subclass as:
>
> ------------
> MySerialReader = New cSerialReader
>
> mySerialReader.Port = 0
> mySerialReader.Baud = 8
> mySerialReader.Bits = 3
> mySerialReader.Stop = 0
> mySerialReader.Parity = 0
>
> if Not mySerialReader.Open Then
> msgBox "Ouverture série impossible"
> End if
> ------------
>
> ...and the IDE crash at : mySerialReader.Open...
>
> I saw that Serial has an other property: serialPort, I don't know if it is
> needed but in debug mode this property appears to be NIL. Maybe it's the
> cause of my crash ? How can I set up this property ?

--
Günte

Re: Serial Stuff...
Date: 28.08.02 14:55 (Wed, 28 Aug 2002 15:55:08 +0200)
From: Stéphane Pinel <
Le 28/08/02 15:41, « Frank Bitterlich » <<email address removed>> a écrit :

> How does the IDE crash? Do you get a console crashlog? If so, you should
> send it to RS with a REALbugs report.
>
> It might indeed be necessary to set the SerialPort property. I haven't
> used it yet, but IIRC you must use something like
> "mySerialReader.SerialPort = System.SerialPort(n)", where n is in
> [0..System.SerialPortCount-1].

That's what I did and everything runs fine now...

>But in any case it shouldn't cause a crash.

It did (in Fact). The strange thing is that using Serial Control, I haven't
set any SerialPort. Maybe RB sets SerialPort(0) by default. It doesn't look
like a bug...we just have to trap this...?

Thanks.


--
St