Code:
#ifndef __SERIAL_H__
#define __SERIAL_H__
#define FC_DTRDSR 0x01
#define FC_RTSCTS 0x02
#define FC_XONXOFF 0x04
#define ASCII_BEL 0x07
#define ASCII_BS 0x08
#define ASCII_LF 0x0A
#define ASCII_CR 0x0D
#define ASCII_XON 0x11
#define ASCII_XOFF 0x13
class CSerial
{
public:
CSerial();
~CSerial();
BOOL Open( int nPort = 2, int nBaud = 9600 );
BOOL Close( void );
int ReadData( void *, int );
int SendData( const char *, int );
int ReadDataWaiting( void );
BOOL IsOpened( void ){ return( m_bOpened ); }
protected:
BOOL WriteCommByte( unsigned char );
HANDLE m_hIDComDev;
OVERLAPPED m_OverlappedRead, m_OverlappedWrite;
BOOL m_bOpened;
};
#endif
here is the file that i'm trying to insert serial.h into
Code:
#include "rt100.h"
//#include "zpr.h"
#include "Serial.h"
void RT100_Restart(int &error)
// Resets all params stored in the IPs to defaults
{
int pars[8];
pars[7] = error;
RT100_Command(4,pars);
error = pars[7];
}
void RT100_Init_Comms(ToggleMode mode, int debug, int &error)
// Initialises communications with the RT100
{
int pars[8];
pars[0] = (int)mode;
pars[1] = debug;
pars[7] = error;
RT100_Command(2,pars);
error = pars[7];
}
void RT100_Define_Origin(int &error)
// Defines the current position to be the origin by setting all position and
// error counts to 0
{
int pars[8];
pars[7] = error;
RT100_Command(5,pars);
error = pars[7];
}
void RT100_Version(int &libver, int &librev, int &romver, int &error)
// Returns the library version, revision, and ROM version
{
int pars[8];
pars[7] = error;
RT100_Command(3,pars);
libver = pars[4];
librev = pars[5];
romver = pars[6];
error = pars[7];
}
void RT100_Set_Mode(Motor motor, MotorMode mode, int &error)
// Sets a motor into one of the three input modes
{
int pars[8];
pars[0] = (int)motor;
pars[1] = (int)mode;
pars[7] = error;
RT100_Command(7,pars);
error = pars[7];
}
void RT100_Read(Motor motor, DataCode code, int &data, int &error)
// Reads a data code from any motor
{
int pars[8];
pars[0] = (int)motor;
pars[1] = (int)code;
pars[7] = error;
RT100_Command(12,pars);
data = pars[6];
error = pars[7];
}
void RT100_Write(Motor motor, DataCode code, int data, int &error)
// Sets the value in a data code for any motor
{
int pars[8];
pars[0] = (int)motor;
pars[1] = (int)code;
pars[2] = data;
pars[7] = error;
RT100_Command(13,pars);
error = pars[7];
}
void RT100_Go(GoMode mode, int gobits, int &error)
// Sets one or more motors moving in one of the three drive modes
{
int pars[8];
pars[0] = (int)mode;
pars[1] = gobits;
pars[7] = error;
RT100_Command(9,pars);
error = pars[7];
}
void RT100_Interpolate(IntData data, int &error)
// Moves each motor by the increment given in the array movement_data
{
int pars[8];
pars[0] = data[(int)ELBOW];
pars[1] = data[(int)SHOULDER];
pars[2] = data[(int)ZED];
pars[3] = data[(int)WRIST1];
pars[4] = data[(int)WRIST2];
pars[5] = data[(int)YAW];
pars[6] = data[(int)GRIP];
pars[7] = error;
RT100_Command(14,pars);
error = pars[7];
}
void RT100_General_Status(int &status, int &error)
// Returns a status variable for the RT100
{
int pars[8];
pars[7] = error;
RT100_Command(11,pars);
status = pars[6];
error = pars[7];
}
void RT100_Motor_Status(Motor motor, int &status, int &error)
// Returns a status variable for a particular motor
{
int pars[8];
pars[0] = (int)motor;
pars[7] = error;
RT100_Command(10,pars);
status = pars[6];
error = pars[7];
}
void RT100_Stop(StopMode mode, int &error)
// Stops all motors in one of the stop modes
{
int pars[8];
pars[0] = (int)mode;
pars[7] = error;
RT100_Command(8,pars);
error = pars[7];
}
void RT100_Raw_Command(int IP, int num_bytes, char byte1, char byte2, char byte3, int &error)
// Sends a raw IPC command to the specified IP
{
int pars[8];
pars[0] = IP;
pars[1] = num_bytes;
pars[2] = byte1;
pars[3] = byte2;
pars[4] = byte3;
pars[7] = error;
RT100_Command(0,pars);
error = pars[7];
}
void RT100_Raw_Response(int IP, int &num_bytes, char &byte1, char &byte2, char &byte3, int &error)
// Gets a raw IPC response from the specified IP
{
int pars[8];
pars[0] = IP;
pars[7] = error;
RT100_Command(1,pars);
num_bytes = pars[3];
byte1 = pars[4];
byte2 = pars[5];
byte3 = pars[6];
error = pars[7];
}
void RT100_Reload_PIDS(int &error)
// Eh?
{
int pars[8];
pars[7] = error;
RT100_Command(6,pars);
error = pars[7];
}
void RT100_Soak(Soak soak, int &error)
// Uh?
{
int pars[8];
pars[0] = (int)soak;
pars[7] = error;
RT100_Command(15,pars);
error = pars[7];
}
void RT100_Command(int command, int pars[8])
// Sends the command to the RT100 directly. Used by all other functions.
{
if (pars[7] != 0) return;
if (!RT100_Library_Installed())
{
pars[7] = LIBRARY_NOT_INSTALLED;
return;
}
//union REGS regs;
//regs.x.ax = command;
//regs.x.bx = FP_OFF(pars);
//regs.x.cx = FP_SEG(pars);
//int86(0x78, ®s, ®s);
}
int RT100_Library_Installed(void)
// Checks that the library is installed correctly
// Hmmm. This isn't actually implemented.
{
return(1);
}