The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024

Latest message you have seen: RE: Re: Vendor / Developer ID Question.


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

RE: XPL CM12 Service


  • Subject: RE: XPL CM12 Service
  • From: Tony T
  • Date: Tue, 01 Apr 2003 21:37:00 +0000

> The XPL CM12 service code is now complete - however it
> doesn't work :-(

Don't you just hate it when that happens ;-)

> If you try and compile it as a service, you end up with
> strange errors at runtime, relating to the use of the
> CM11a.ocx component.

This is probably like my problems trying to use the winsock ocx in an asp
dll?

> So as far as I can tell, the only way to go is to investigate
> talking to the serial port directly from .NET, removing the
> need for the cm11a ActiveX completely.

This might help, but I havent tried it...

Initializing and Opening the Com port

Create an instance of CRs232 then set COM parameters before invoking the
Open method

Here's an example:

Dim moRS232 as New CRs232()
With moRs232
.Port = 1
'// Uses COM1
.BaudRate = 2400 '//
2400 baud rate
.DataBit = 8
'// 8 data bits
.StopBit = CRs232.DataStopBit.StopBit_1 '// 1 Stop bit
.Parity = CRs232.DataParity.Parity_None '// No Parity
.Timeout = 500 '//
500 ms of timeout admitted to get all required bytes
End With

'// Initializes and Open
moRS232.Open()

You can, optionally control the state of DTR/RTS lines after the Port is
open

'// Set state of RTS / DTS
moRS232.Dtr = True
moRS232.Rts = True

In case of an error/problems an exception is raised, so i suggest you to
enclose the code within a Try...Catch block.

Transmitting data to COM Port

The class has 2 buffers one for Tx and one for Rx, to transmit data just
set the TxData property with the informations you wish to send then invoke
the Tx method.

example:

moRS232.TxData = txtTx.Text
moRS232.Tx()

Receiving data from COM Port

Just invoke the Rx method passing it the number of bytes you want to read
from COM port, then read the Rxdata property.

example:

moRS232.Rx(10) '// Gets 10 bytes from serial
communication buffer
Dim sRead as String=moRs232.RxData

Please note that thread is blocked for the period of time set by Timeout
property and that in case the class cannot read all required bytes from COM
buffer a Timeout exception is raised.
If the number of bytes to read is omitted, the class assumes 512 bytes have
to be read from buffer.

This is from <a href="http://66.216.11.86/cc/VBNetRs232.htm";>http://66.216.11.86/cc/VBNetRs232.htm</a>

Regards
Tony






xPL Main Index | xPL Thread Index | xPL Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.