>>>>> Serial Communications 
Author Message
 >>>>> Serial Communications

I have been tasked with writing a software package that sends commands
through a serial cable.  I am not really sure how to do this, I have sent
serial commands to a modem before but that's it.

If anyone knows of a resource that outlines this process, or a website that
may describe it, I would greatly appreciate it.

Thank you,
Jim

(Please post replies within group)



Mon, 04 Sep 2000 03:00:00 GMT  
 >>>>> Serial Communications

Jim,

while it doesn't go into a whole lot of detail, the MSComm control may well do
everything you need for serial communications.  Search for help using
'Communication' in the Find option.  I've been using this control for serial
communications and it is working fine.

Gareth Hatch



Mon, 04 Sep 2000 03:00:00 GMT  
 >>>>> Serial Communications

Quote:

> I have been tasked with writing a software package that sends
> commands through a serial cable.  I am not really sure how to
> do this, I have sent serial commands to a modem before but
> that's it.
> If anyone knows of a resource that outlines this process, or a
> website that may describe it, I would greatly appreciate it.
> Thank you,
> Jim

You should use the MsComm Control.  
If you're sending commands to a pre-defined device, then
get the manual or spec for that device.  It will tell the
message that you need to use.
If you are allowed to define the format, then you could
use the NMEA-0183 spec.  It's used by marine and GPS devices
to talk to each other.  The info is here:

   ftp://sundae.triumf.ca/pub/peter/index.html

You'll need to create a COMMLIB.BAS module, that
has these four functions:

Function b_CommOpen (ctl_Comm As Control) As Integer
Function b_CommClose (ctl_Comm As Control) As Integer
Function b_CommSendMessage (ctl_Comm As Control,
                             s_Message As String) As Integer
Function b_CommReceiveMessage (ctl_Comm As Control,
                           s_Message As String) As Integer

The MsComm control is passed in as a parameter.

In the b_CommReceiveMessage function, the string
that is received from the device is passed back
by reference to the caller.

Each function returns a boolean value that just tells
the calling code SUCCESS or FAILURE.

The Send and Receive functions, above, each have a
Do Loop that does the major action.  The MsComm
control is queried (via reading a property) to
see if it can accept, or has a character ready,
respectively.  Read the MsComm help file on
its properties for detailed info.

You'll need to check if the Do Loop timed out, in
each case.  Here's some sample code for that part:  

Dim dte_Timeout As Variant  'Define the Timeout value

'Init the timeout time. Note: COMM_RECEIVE_TIMEOUT = 5
dte_Timeout = Now + TimeSerial(0, 0, COMM_RECEIVE_TIMEOUT)

Do
.
.
.
  If (Now >= dte_Timeout) Then       'Did we time out ?
     s_ErrorMsg = "Timed out while waiting for message."
     b_Retval = FAILURE              'If so, exit the loop
     GoTo b_CommReceiveMessage_Exit
  End If
.
.
.
Loop

(I've left the main loop code out of this example.)

This timeout code is only accurate to +/- 1 second, but
for the short messages I'm sending (500 chars max)
and the baud rate (4800,N,8,1), it works fine.

This should at least get you started.



Mon, 04 Sep 2000 03:00:00 GMT  
 >>>>> Serial Communications

Thank you for the info.  Here is a little information about the device I am
connecting to:

'Communication is performed on this RS232 interface with ASCII coded data (8
bit).  A command to this device consists of an address byte and a command
block.  This device responds to each command with an acknowledge block.'

Address byte has following structure:
7  6  5  4  3  2  1  0
1  |     ( address byte)
    >0 or 1 for acknowledge

Sample command:
Byte  Length   Constants   Meaning
0        1             STX            Start of Text, 02 hex
1        2             02               2 bytes to follow, excluding ETX
3        2             23               command code
5        1             ETX            End of Text, 03 hex

Sample Acknowledge Block:
Byte   Length   Constants  Meaning
0        1              STX           Start of Text, 02 hex
1        2               4                4 bytes to follow, excluding ETX
3        2              23              echo of command code
5        2              xx                return code
7        1              ETX           end of text, 03 hex

If you can help get me started, I would be very grateful.  This project is
driving me nuts.

Thank you,
Jim
(Please post replies within group)



Tue, 05 Sep 2000 03:00:00 GMT  
 >>>>> Serial Communications

Quote:

>I have been tasked with writing a software package that sends commands
>through a serial cable.  I am not really sure how to do this, I have sent
>serial commands to a modem before but that's it.

>If anyone knows of a resource that outlines this process, or a website that
>may describe it, I would greatly appreciate it.

>Thank you,
>Jim

>(Please post replies within group)

Check out

 http://www.mabry.com/vbpgser/index.htm
 for information on a book called:

Visual Basic Programmer's Guide To Serial Communications

Regards,
Michael E. Floyd
Regards,
Michael E. Floyd



Thu, 14 Sep 2000 03:00:00 GMT  
 >>>>> Serial Communications

If it's fairly simple stuff, like programming terminals, dialing a phone thru a modem, etc.,  just open the com port with the Open statement and "print" the data out.

--
Mark Harr
LDA Systems, Inc.

|

|
|>I have been tasked with writing a software package that sends commands
|>through a serial cable.  I am not really sure how to do this, I have sent
|>serial commands to a modem before but that's it.
|>
|>If anyone knows of a resource that outlines this process, or a website that
|>may describe it, I would greatly appreciate it.
|>
|>Thank you,
|>Jim
|>
|>(Please post replies within group)
|>
|
|Check out
|
| http://www.mabry.com/vbpgser/index.htm
| for information on a book called:
|
|Visual Basic Programmer's Guide To Serial Communications
|
|Regards,
|Michael E. Floyd
|Regards,
|Michael E. Floyd



Fri, 15 Sep 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. <<<<<<<<ComboBox>>>>>>>>>>>>

2. using The Shell Command >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

3. >>>>>>While Not rst.EOF

4. PSUDOCODE HELP >>>>>>>>>>>

5. VB5 >>>>> Academic Version

6. <<<<HELP- OLE container Control>>>>>>>>>

7. !!! URGENT HELP REQUIRED !!!>>>>>>>>

8. >>= bitwise operations >>

9. Please Help --------->>>>AppLink Problem

10. VB3 ->->->->VBDOS??

11. >>>> HELP WITH RUNTIME FILES

12. >>>> Tab Key --- Please Help

 

 
Powered by phpBB® Forum Software