Gå til innhold

Kontrollere Serial port fra VB


Anbefalte innlegg

Videoannonse
Annonse

Ellers kan du bruke Communications Control, Microsoft Comm Control 6.0

 

 

MSDN:

Opening the Serial Port

To open a serial port, use the CommPort, PortOpen, and Settings properties. For example:

 

' Open the serial port

MSComm1.CommPort = 2

MSComm1.Settings = "9600,N,8,1"

MSComm1.PortOpen = True

 

The CommPort property sets which serial port to open. Assuming that a modem is connected to COM2, the above example sets the value to 2 (COM2) and connects to the modem. You can set the CommPort property value to any number between 1 and 16 (the default is 1). If, however, you set this value to a COM port that does not exist for the system on which your application is run, an error will be generated.

 

The Settings property allows you to specify the baud rate, parity, and the number of data bits and stop bits. By default, the baud rate is set at 9600. The parity setting is for data validation. It is commonly not used, and set to "N". The data bits setting specifies the number of bits that represent a chunk of data. The stop bit indicates when a chunk of data has been received.

 

Once you’ve specified which port to open and how data communication is to be handled, you use the PortOpen property to establish the connection. It is a Boolean value, True or False. If, however, the port is not functional, if the CommPort property is set incorrectly, or if the device does not support the settings you’ve specified, an error will be generated or the external device may not work correctly. Setting the value of the PortOpen property to False closes the port.

 

Lenke til kommentar

Sånn rent umiddelbart så føles det som om Parallell porten er mye bedre for dette, altså om man skal ha "statiske" logiske signaler ut av dataen. (for switcher og slikt).

 

Serie-porten sender jo bare serielt data med start og stopp biter, altså blir det ingen konstant nivå for switchen.

 

Det finns jo noen pinner som man kan bruke, disse var jo tenkt for "hand-shake" i elektronikken. Transmit enable og slike.. disse burde man også kunne kontrollere og sette til låg eller høg, men det er ikke så veldig mange av disse.. Spørss hvor mange du trenger mao.

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...