tron1@tronsbox.xei.com (HIM) (09/05/90)
Ok , I am playing (!) with the Lattice C++ compiler .. I know there are a LOT of bugs , but I don't have anything better to do right now ;-). Anyway , I want to make a class for the serial port , the standard IOStdReq is NOT set up for serial IO really. Anyway , the problem I am having is that The following code feezes with NO output to the conole and only the first write() seems to execute and never return. Any comments welcome! (BTW -- sorry that the TABS are gone... they dont matter much and I dont feel like re-writing the upload software tonight. ------------------- cpp_serial.h ------------------- //Into the breach as they say .. here we will //implement a complete interface to the Amiga serial // port in C++. #include <stream.h> #include <exec/types.h> #include <devices/serial.h> #include <string.h> #define DEVICE_NAME "serial.device" #define UNIT_NUMBER 0 #define BAUD 19200 class Serial_Port { MsgPort ser_msg_port; IOExtSer ser_msg; char device_name[100]; int unit_number; int status; public: Serial_Port(); int Serial_Port(int); //int Set_Baud(int); //int Status(); int Open_Port(); int WSend_Char( char *); int WSend_Line( char *); //char WGet_Char(char); //char Get_Char(char); //int Send_Char(char); int Close_Port(); }; Serial_Port::Serial_Port(){ // The constructor for the whole thing sprintf(device_name,"%s", DEVICE_NAME); // Default Amiga port unit_number = UNIT_NUMBER;// Default Amiga port }; int Serial_Port::Open_Port(){ // Open the beast for use..... int result; result = ser_msg.open("serial.device"); if( result ) { // Set up initial speed and stuff ser_msg.io_Command = SDCMD_SETPARAMS; ser_msg.io_SerFlags = SERF_SHARED; ser_msg.io_Baud = BAUD; ser_msg.do_io(); ser_msg.wait(); result = ser_msg.error(); } status = result; return(result); }; int Serial_Port::Close_Port(){ // Close the bloody thing ! int result; ser_msg.close(); result = ser_msg.error(); status = result; return(result); }; int Serial_Port::WSend_Char(char * outchar){ // Send a single character int result; ser_msg.write( (APTR)outchar , (int) 1); result = ser_msg.error(); status = result; return(result); }; int Serial_Port::WSend_Line(char *outchars){ // Send a full line out int result; ser_msg.write( (APTR)outchars , strlen(outchars) ); result = ser_msg.error(); status = result; return(result); }; ------------------------------------------------------------------- Here is the driver program to test the above..... ---------------------- test.cp ----------------------------------- #include "Cpp_serport.h" void main(){ cout << "Staring up !-- Hello World !!\n"; Serial_Port myser; cout << "Calling the openserial routine now ... \n"; cout << myser.Open_Port() << "\n"; cout << "Sending data out the port ! ... \n"; cout << myser.WSend_Line( "Hello world 1 !!! \n" ); cout << "Sending data out the port ! ... \n"; cout << myser.WSend_Line( "Hello world 2 !!!\n " ); cout << "Calling the closeserial routine now ... \n"; cout << myser.Close_Port() << "\n"; cout << "DONE! I LIVE , I LIVE !\n"; } ========[ Xanadu Enterprises Inc. Amiga & Unix Software Development]======== = "And in the darkened offices, the terminals shine like stars." = ============= Ken Jamieson: uunet!tronsbox.xei.com!tron1 ================== = NONE of the opinions represented here are endorsed by either = = Xanadu Enterpises or its clients, AT&T Bell Labs or others. = ==== The Romantic Encounters BBS 201-759-8450(PEP) / 201-759-8568(2400) ====