virtual serial port triggers

false74

Well-known member
Joined
Aug 4, 2010
Messages
76
Programming Experience
Beginner
I have looked around and read a few things on serial ports and what not, but I don't fully understand them still. What I am looking to create is a virtual com port that virtually connects pins 7 and 8 together (on a RS232). Is there an easy way to do this, or can anyone point me in the right direction?

this is what i have:
VB.NET:
Private virtualport As New SerialPort

in the form load:
VB.NET:
 Try
            virtualport.Open()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
 
the SerialPort class does not give you individual access to the pins states.
also, I don't know of any vb.net class that would do it.
If you want individual pins, it might be easier to use the parallel port instead.

what you created with your code will allow you to use virtualport.write(myString) and virtualport.read() and other related functions.
 
It needs to be a serial connection, because I am trying to control another piece of software that is controlled via serial triggers. When 2 pins are triggered doesn't it send a message? There is no way to emulate this?
 
I'm sorry but what you're saying is not making much sense.
The serial port sends data as a sequence of bits usually coding ASCII characters.

You do not individually control it's pins. You simply instantiate the SerialPort object, open it and use a mySerialPort.Write(MessageString) to communicate...
 
So there is no way possible to emulate connecting pins 7 and 8 together virtually? pin 7 means "request to send" and pin 8 means "clear to send". Anyways of sending serial commands, such as those, can I do that?
 
ok a little more digging and i found this: you can set/get RTS (request to send aka pin 7) and CTS (clear to send aka pin 8) using a windows api called "setcommstate".
I found this info here: how to read rts/cts status on serial port - C++ (it was for c++ with no real answer given, just some info).

some more digging (for vb.net code/api) and i found this: How to access serial and parallel ports by using Visual Basic .NET an api called "mscomm"

after that i found some simple code here: COM port made simple with VB.NET - CodeProject

but I don't know how to use it, I think i would be interested in the setcommstate method, but I dont know what the parameters are?

VB.NET:
  <DllImport("kernel32.dll")> Private Shared Function SetCommState( _
    ByVal hCommDev As Integer, ByRef lpDCB As DCB) As Integer
    End Function

any opinions? or am I just hopelessly lost and confused
 
well....
despite the fact that you found this, from my experience I still doubt the usefulness of individually accessing pins on the serial port.
I suggest double checking the documentation of what you're trying to control before going further on this.

But if it's really what you need, a simple google: "vb.net use windows api" will show you several articles on how windows API's are used in vb.net and you can adapt the example you found in c++ to vb.net
 
Back
Top