C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-11-2005, 07:16 AM   #1
Registered User
 
Join Date: Jun 2005
Posts: 8
very weird .h problem

hello, peeps! i'm having trouble figuring out what the problem is with my program. i got this .h (Serial.h) file from a site that works very well with all the programs that i've used that .h file.

but when insert "serial.h" to another file (RT100.cpp), i got all these errors that i've never seen before when i used "serial.h" with my other program.

here is serial.h

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, &regs, &regs);
}

int  RT100_Library_Installed(void)
// Checks that the library is installed correctly
// Hmmm. This isn't actually implemented.
{
return(1);
}

these are the errors i get after compilation:

c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(23) : error C2146: syntax error : missing ';' before identifier 'Open'
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(23) : error C2501: 'BOOL' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(24) : error C2146: syntax error : missing ';' before identifier 'Close'
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(24) : error C2501: 'BOOL' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(30) : error C2146: syntax error : missing ';' before identifier 'IsOpened'
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(30) : error C2501: 'BOOL' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(30) : warning C4183: 'IsOpened': member function definition looks like a ctor, but name does not match enclosing class
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(33) : error C2146: syntax error : missing ';' before identifier 'WriteCommByte'
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(33) : error C2501: 'BOOL' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(35) : error C2146: syntax error : missing ';' before identifier 'm_hIDComDev'
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(35) : error C2501: 'HANDLE' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(35) : error C2501: 'm_hIDComDev' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(36) : error C2146: syntax error : missing ';' before identifier 'm_OverlappedRead'
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(36) : error C2501: 'OVERLAPPED' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(36) : error C2501: 'm_OverlappedRead' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(36) : error C2501: 'm_OverlappedWrite' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(37) : error C2146: syntax error : missing ';' before identifier 'm_bOpened'
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(37) : error C2501: 'BOOL' : missing storage-class or type specifiers
c:\documents and settings\raj ching\my documents\rt100 control library c++\serial.h(37) : error C2501: 'm_bOpened' : missing storage-class or type specifiers
Error executing cl.exe.

RT100.OBJ - 18 error(s), 1 warning(s)

what did i do wrong? any advice would be greatly appreciated
royuco77 is offline   Reply With Quote
Old 09-11-2005, 07:55 AM   #2
Registered User
 
Join Date: Mar 2004
Posts: 535
Quote:
Originally Posted by royuco77
i'm having trouble figuring out what the problem is with my program.
.
.
.

any advice would be greatly appreciated
Code:
#include <windows.h>
Regards,

Dave
Dave Evans is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with load mesh when its in its own cpp and .h Anddos Game Programming 6 04-14-2007 07:07 AM
very weird problem (pointers I think) hannibar C Programming 2 10-11-2005 06:45 AM
a weird problem with my code on writing & reading from file goldfish C Programming 6 05-12-2005 03:39 AM
Weird mouse problem in XP Bubba Game Programming 5 06-16-2004 11:47 AM
Weird class problem! aker_y3k C++ Programming 2 09-25-2002 06:12 AM


All times are GMT -6. The time now is 11:54 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22