beautypg.com

Rane ECS RaneWare User Manual

Page 32

background image

RW Manual-32

RW 232 Communications Interface

RW 232 is loosely based on PA-422. One key hardware difference is that RW 232 does not utilize hardware handshaking via

DTR/DSR. The beginning of a message always takes the form:

$FB xx FB xx (where xx = ADDR)

Input port: 9-pin female input port (DB-9F) on device
Output port: 9-pin male output port (DB-9M) on device (for serial linking to the input port on the next device. Up to 16

devices at a time can be linked in this manner.)

Device address means: 8 position DIP switch on device (valid device addresses are 1 through 250)
Baud Rate: 19.2 kilobaud
Character frame bits: 1 start bit, 8 data bits, 1 parity bit (even), and 1 stop bit
Cabling: Use standard RS-232 serial printer or modem cables. Warning: NULL modem cables will not work!
Host or computer interface:Standard PC serial COM port (DB-9M, or DB-25M with adapter)
Note: When $FB appears in the body of the message, it is always repeated.
Note: Only three lines, Tx, Rx, and Ground, are used.

Example Packet Expansion code for RW 232 Messages

// (Derived from RW232.CPP code) This code only deals with the Body of an RW 232 message (Command/Data)
// The steps needed to fully communicate with an RW 232 device are as follows:
// 1. Send the Address: [FB xx FB xx]
// 2. Get the returned Device Type and Device ID flags
// 3. Send the FB expanded Body
// 4. Get and check the returned ComStat byte
// Take a simple command and expand it into a full packet.
//
// Input:
//

Buff

- BYTE array with the unexpanded message and lots of extra room

//

MsgLen - Unexpanded message length

//
// Steps required are:
// 1. Add Packet size. This is simply the Command length + 1 for the checksum
// 2. Duplicate 0xFBs
// 3. Calculate Checksum
// 4. Add Checksum to packet (Check for a 0xFB Checksum!)
// 5. Copy Packet back to the buffer
// 6. Return the new Packet Size
// Note: The buffer must be large enough to accept the expanded data. No checking is done to verify it is, so be careful!
// A packet into this routine consists of the one byte Command and any Data
int CmdToPacket(BYTE Buff[], int MsgLen)
{
BYTE L_MSB = ((MsgLen+1) >> 8) & 0xFF;

// Grab MSB of Size

BYTE L_LSB = (MsgLen+1) & 0xFF;

// Grab LSB of Size

// FBs is the number of 0xFB bytes in the messages
int FBs = 0;
// Don’t forget to check message length for FBs
if (L_MSB == 0xFB)
FBs ++;
if (L_LSB == 0xFB)
FBs ++;
// Calculate Checksum of Message Length bytes along with bytes in the packet
int CheckSum = L_MSB + L_LSB;
for (int x=0;x{
CheckSum += Buff[x];
if (Buff[x] == 0xFB)
FBs ++;
}

©Rane Corporation 10802 47th Ave. W., Mukilteo WA 98275-5098 TEL (425)355-6000 FAX (425)347-7757 WEB http://www.rane.com

PN 12495