473,471 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

RS232 Anyone???

I'm trying to use the RS232 class that was in the Platform SDK (i think).
Has anyone else used this with events successfully? Here's what i've got:
======================
Public WithEvents bbsPort As Rs232 = New Rs232

With bbsPort
.BaudRate = baud
.DataBit = dataBits
.Parity = parity
.Port = comPort
.StopBit = stopBits
Try
.Open()
Catch ex As Exception
StopServerToolStripMenuItem.PerformClick()
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End With

'The port opens okay because if I have another application using the port I
get the exception message "Unable to open COM1"

Public Sub ReadComPort(ByVal Source As Rs232, ByVal DataBuffer() As Byte)
Handles bbsPort.DataReceived
MsgBox("DataReceived")
End Sub
=======================

Two questions I have are: I know I can communicate because I can talk to
the serial device with Hyperterminal. When I try it with my app, the event
is never fired. So I must be doing something wrong. Any help is
desperately needed & appreciated.

Second question: There doesn't seem to be a way to set flow control. Has
anyone added flow control capabilities to this class?

Thanks.
Nov 21 '05 #1
8 2038
Nevermind....I just found out that VB 2005 supports the serial ports.
Changed my code and all works fine now...
"Terry Olsen" <to******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I'm trying to use the RS232 class that was in the Platform SDK (i think).
Has anyone else used this with events successfully? Here's what i've got:
======================
Public WithEvents bbsPort As Rs232 = New Rs232

With bbsPort
.BaudRate = baud
.DataBit = dataBits
.Parity = parity
.Port = comPort
.StopBit = stopBits
Try
.Open()
Catch ex As Exception
StopServerToolStripMenuItem.PerformClick()
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End With

'The port opens okay because if I have another application using the port
I get the exception message "Unable to open COM1"

Public Sub ReadComPort(ByVal Source As Rs232, ByVal DataBuffer() As Byte)
Handles bbsPort.DataReceived
MsgBox("DataReceived")
End Sub
=======================

Two questions I have are: I know I can communicate because I can talk to
the serial device with Hyperterminal. When I try it with my app, the
event is never fired. So I must be doing something wrong. Any help is
desperately needed & appreciated.

Second question: There doesn't seem to be a way to set flow control. Has
anyone added flow control capabilities to this class?

Thanks.

Nov 21 '05 #2
2005 is not released yet, so if your planning this for a production target
you may be leaving yourself with a problem if they take out the support on
the release version.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Terry Olsen" <to******@hotmail.com> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
Nevermind....I just found out that VB 2005 supports the serial ports.
Changed my code and all works fine now...
"Terry Olsen" <to******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I'm trying to use the RS232 class that was in the Platform SDK (i think). Has anyone else used this with events successfully? Here's what i've got: ======================
Public WithEvents bbsPort As Rs232 = New Rs232

With bbsPort
.BaudRate = baud
.DataBit = dataBits
.Parity = parity
.Port = comPort
.StopBit = stopBits
Try
.Open()
Catch ex As Exception
StopServerToolStripMenuItem.PerformClick()
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End With

'The port opens okay because if I have another application using the port I get the exception message "Unable to open COM1"

Public Sub ReadComPort(ByVal Source As Rs232, ByVal DataBuffer() As Byte) Handles bbsPort.DataReceived
MsgBox("DataReceived")
End Sub
=======================

Two questions I have are: I know I can communicate because I can talk to the serial device with Hyperterminal. When I try it with my app, the
event is never fired. So I must be doing something wrong. Any help is
desperately needed & appreciated.

Second question: There doesn't seem to be a way to set flow control. Has anyone added flow control capabilities to this class?

Thanks.


Nov 21 '05 #3
Hi Terry,
2005 is not released yet, so if your planning this for a production target
you may be leaving yourself with a problem if they take out the support on
the release version.


A very good answer to Terry and in general.

:-)

Cor
Nov 21 '05 #4
It's a personal project.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:u5******************@TK2MSFTNGP14.phx.gbl...
2005 is not released yet, so if your planning this for a production target
you may be leaving yourself with a problem if they take out the support on
the release version.

Nov 21 '05 #5
The logic stands, however, its obviously your call.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Terry Olsen" <to******@hotmail.com> wrote in message
news:es*************@tk2msftngp13.phx.gbl...
It's a personal project.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:u5******************@TK2MSFTNGP14.phx.gbl...
2005 is not released yet, so if your planning this for a production target you may be leaving yourself with a problem if they take out the support on the release version.


Nov 21 '05 #6
Hi Terry,

I'm planning to make anapplication that has to communicate with an SMS
Modem. I kind of drawned in the lots of bad RS232 code I foudn and tested.

I'm also tempted to do it in VS 2005 because I heard it was integrated
there. Does your code works fine? And did you use the VS 2005 Beta 1 or the
VS 2005 Express Edition? Is it possible to make a working Service with it
that uses RS232?

If you woudl be so kind to paste your code that would be very helpfulltoo
:-)

Thanks a lot in advance,

Pieter

"Terry Olsen" <to******@hotmail.com> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
Nevermind....I just found out that VB 2005 supports the serial ports.
Changed my code and all works fine now...
"Terry Olsen" <to******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I'm trying to use the RS232 class that was in the Platform SDK (i think). Has anyone else used this with events successfully? Here's what i've got: ======================
Public WithEvents bbsPort As Rs232 = New Rs232

With bbsPort
.BaudRate = baud
.DataBit = dataBits
.Parity = parity
.Port = comPort
.StopBit = stopBits
Try
.Open()
Catch ex As Exception
StopServerToolStripMenuItem.PerformClick()
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End With

'The port opens okay because if I have another application using the port I get the exception message "Unable to open COM1"

Public Sub ReadComPort(ByVal Source As Rs232, ByVal DataBuffer() As Byte) Handles bbsPort.DataReceived
MsgBox("DataReceived")
End Sub
=======================

Two questions I have are: I know I can communicate because I can talk to the serial device with Hyperterminal. When I try it with my app, the
event is never fired. So I must be doing something wrong. Any help is
desperately needed & appreciated.

Second question: There doesn't seem to be a way to set flow control. Has anyone added flow control capabilities to this class?

Thanks.


Nov 21 '05 #7
I'm using the Express version Beta 1 downloadable from Microsoft.

I don't have too much in the way of functionality yet as my time to work on
it is very limited. But it's pretty straight forward. When you install the
Express version, you also get the MSDN library that goes with it..so it's
all in the docs. But here are some snippets of what I have so far...it
receives input from the COM port using a ReceivedEvent and throws up a
messagebox with the received character.
Imports System.IO.Ports
Public WithEvents bbsPort As SerialPort = New SerialPort

For Each sp As String In My.Computer.Ports.SerialPortNames
If IsPortAvailable(sp) Then cboComPort.Items.Add(sp)
Next

Public Function IsPortAvailable(ByVal port As String) As Boolean
' This function attempts to open the passed Comm Port. If it is
' available, it returns True, else it returns False. To determine
' availability a Try-Catch block is used.
Try
bbsPort.PortName = port
bbsPort.Open()
' If it makes it to here, then the Comm Port is available.
bbsPort.Close()
Return True
Catch
' If it gets here, then the attempt to open the Comm Port
' was unsuccessful.
Return False
End Try
End Function

With bbsPort
.BaudRate = baud
.DataBits = dataBits
.Parity = parity
.PortName = comPort
.StopBits = stopBits
.Handshake = flowControl
.ReceivedBytesThreshold = 1
Try
.Open()
Catch ex As Exception
StopServerToolStripMenuItem.PerformClick()
MsgBox(ex.Message, MsgBoxStyle.Critical, "Telnet2BBS")
End Try
End With

Public Sub ReadComPort(ByVal Sender As Object, ByVal e As
System.IO.Ports.SerialReceivedEventArgs) Handles bbsPort.ReceivedEvent
Try
MsgBox(Chr(bbsPort.ReadByte))
Catch ex As Exception
Exit Sub
End Try
End Sub

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Terry,

I'm planning to make anapplication that has to communicate with an SMS
Modem. I kind of drawned in the lots of bad RS232 code I foudn and tested.

I'm also tempted to do it in VS 2005 because I heard it was integrated
there. Does your code works fine? And did you use the VS 2005 Beta 1 or
the
VS 2005 Express Edition? Is it possible to make a working Service with it
that uses RS232?

If you woudl be so kind to paste your code that would be very helpfulltoo
:-)

Nov 21 '05 #8
Thanks! I'm gona try to download it and play a bit arround!
:-)

"Terry Olsen" <to******@hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP15.phx.gbl...
I'm using the Express version Beta 1 downloadable from Microsoft.

I don't have too much in the way of functionality yet as my time to work on it is very limited. But it's pretty straight forward. When you install the Express version, you also get the MSDN library that goes with it..so it's
all in the docs. But here are some snippets of what I have so far...it
receives input from the COM port using a ReceivedEvent and throws up a
messagebox with the received character.
Imports System.IO.Ports
Public WithEvents bbsPort As SerialPort = New SerialPort

For Each sp As String In My.Computer.Ports.SerialPortNames
If IsPortAvailable(sp) Then cboComPort.Items.Add(sp)
Next

Public Function IsPortAvailable(ByVal port As String) As Boolean
' This function attempts to open the passed Comm Port. If it is
' available, it returns True, else it returns False. To determine
' availability a Try-Catch block is used.
Try
bbsPort.PortName = port
bbsPort.Open()
' If it makes it to here, then the Comm Port is available.
bbsPort.Close()
Return True
Catch
' If it gets here, then the attempt to open the Comm Port
' was unsuccessful.
Return False
End Try
End Function

With bbsPort
.BaudRate = baud
.DataBits = dataBits
.Parity = parity
.PortName = comPort
.StopBits = stopBits
.Handshake = flowControl
.ReceivedBytesThreshold = 1
Try
.Open()
Catch ex As Exception
StopServerToolStripMenuItem.PerformClick()
MsgBox(ex.Message, MsgBoxStyle.Critical, "Telnet2BBS")
End Try
End With

Public Sub ReadComPort(ByVal Sender As Object, ByVal e As
System.IO.Ports.SerialReceivedEventArgs) Handles bbsPort.ReceivedEvent
Try
MsgBox(Chr(bbsPort.ReadByte))
Catch ex As Exception
Exit Sub
End Try
End Sub

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Terry,

I'm planning to make anapplication that has to communicate with an SMS
Modem. I kind of drawned in the lots of bad RS232 code I foudn and tested.
I'm also tempted to do it in VS 2005 because I heard it was integrated
there. Does your code works fine? And did you use the VS 2005 Beta 1 or
the
VS 2005 Express Edition? Is it possible to make a working Service with it that uses RS232?

If you woudl be so kind to paste your code that would be very helpfulltoo :-)


Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bob | last post by:
Anyone have a lead on a RS232 software driver that implements the 9th bit protocol? Thanks
7
by: Chris | last post by:
Here's the situation: I work at a scientific institution and I have a portable electronic device which is used to take measurements. The device produces a very small amount of numerical data,...
1
by: Dan | last post by:
I wnat to see in browser an status from an device connected on rs232 port The java class for read from serial port is: //Serial.java import java.io.*; import java.util.*; import...
6
by: Przemo | last post by:
Hi, Do you know some good RS232C class? There is one in VB.NET 101 Examples, but I think it is poor. 1. I can't for e.g. read into my application all data received. I must tell how many...
13
by: jay.dow | last post by:
I want to write to the pins of an RS232 without using the serial protocol. The use would be every pin could act to complete a circuit in customized hardware. I could use python to communicate...
4
by: Dave Harry | last post by:
I found the RS232 class from MS's 101 VB samples. Writing to the port works fine. (I've got hyperterminal on the other comm port and a crossover cable between COM1 and COM2) The port is opened...
6
by: Henning M | last post by:
Hi all, Im trying to send a command to my uprocessor project, but when i try to read the answer for the uPU I get the same commed I just send to it??? It is as if the command isn't send before I...
3
by: ad | last post by:
I am using VS2005 to develop Web application. How can I receive the data from RS232 of client's computer?
1
by: EmmettBrown | last post by:
Hello, Just wondering if anyone can advise. I am trying to remotely control Powerpoint using a microprocessor. I am using RS232 (COM1). The idea is that the microprocessor sends ASCII strings...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.