problems with read data from serial port 
Author Message
 problems with read data from serial port

Hi All

I am a newbie in VB

I want to read from the serial port which is connected through a null -
modem cable to other computer, On the second computer is running Com Port
ToolKit which send string.

I use for reading the following code taken from Help VB6

Private Sub Command1_Click()

Dim Buffer as Variant

Dim Arr() as Byte

' Set and open port

MSComm1.CommPort = 1

MSComm1.PortOpen = True

' Set InputMode to read binary data

MSComm1.InputMode = comInputModeBinary

' Wait until 10 bytes are in the input buffer

Do Until MSComm1.InBufferCount < 10

DoEvents

Loop

' Store binary data in buffer

Buffer = MSComm1.Input

' Assign to byte array for processing

Arr = Buffer

Print "Buffer=", Buffer ' Added by Boris

End Sub

I receive nothing through PRINT, except Buffer =

From the same computer I send from VB program through the same null - modem
cable to the second computer with Com Port ToolKit and receive it

Please help

Boris



Thu, 16 Oct 2003 03:59:30 GMT  
 problems with read data from serial port
perhaps the buffer string consists of ascii codes which do not represent
"printable characters".  characters such as chr(2), which may very well pass
through the serial port, but cannot be displayed by the print method.

--
~~In life, there aren't really any problems ... Only solutions. ~~



Thu, 16 Oct 2003 05:22:06 GMT  
 problems with read data from serial port
Should you not be getting the data in the event :-

Private Sub MSComm1_OnComm()
     ' we have some data to get    
End Sub

======== Snip from VB Help =========
Note   The MSComm control can use polling or an event-driven method to
retrieve data from the port. This simple example uses the polling
method. For an example of the event-driven method, see help for the
OnComm event.
================================

Quote:
>Do Until MSComm1.InBufferCount < 10

>DoEvents

>Loop

That might work - if the buffer had been filled with data before you
got to the routine - otherwise it would pick up nothing.

Actually looking at it more carefully - you are lucky the buffer count
is not 10 or more - otherwise you would be in the loop for ever.

The other poster was quite correct about Print - I would print the
ASCII codes - not the data

On Sat, 28 Apr 2001 21:59:30 +0200, "Boris Skoblo"

Quote:

>Hi All

>I am a newbie in VB

>I want to read from the serial port which is connected through a null -
>modem cable to other computer, On the second computer is running Com Port
>ToolKit which send string.

>I use for reading the following code taken from Help VB6

>Private Sub Command1_Click()

>Dim Buffer as Variant

>Dim Arr() as Byte

>' Set and open port

>MSComm1.CommPort = 1

>MSComm1.PortOpen = True

>' Set InputMode to read binary data

>MSComm1.InputMode = comInputModeBinary

>' Wait until 10 bytes are in the input buffer

>Do Until MSComm1.InBufferCount < 10

>DoEvents

>Loop

>' Store binary data in buffer

>Buffer = MSComm1.Input

>' Assign to byte array for processing

>Arr = Buffer

>Print "Buffer=", Buffer ' Added by Boris

>End Sub

>I receive nothing through PRINT, except Buffer =

>From the same computer I send from VB program through the same null - modem
>cable to the second computer with Com Port ToolKit and receive it

>Please help

>Boris



Thu, 16 Oct 2003 09:41:34 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. DLL for reading serial port data

2. read data from serial port using vba for Access

3. Reading data off of a serial port

4. Reading data from a machine on the serial port

5. WANTED: VB MODULE TO READ DATA FROM SERIAL PORT

6. WANTED: VB MODULE TO READ DATA FROM SERIAL PORT

7. Read data from a serial port

8. read/write data to the serial port

9. Reading serial/parallel port data

10. How to read data from a serial port

11. Problems with Reading from Serial Port

12. Problems reading serial port in WIN NT

 

 
Powered by phpBB® Forum Software