From: Derek J S. <der...@us...> - 2005-03-18 21:06:28
|
Update of /cvsroot/openh323/pwlib/samples/serial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20387 Modified Files: serial.cxx Log Message: Add help messages. Enable different flow control options. Index: serial.cxx =================================================================== RCS file: /cvsroot/openh323/pwlib/samples/serial/serial.cxx,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** serial.cxx 14 Mar 2005 07:33:51 -0000 1.3 --- serial.cxx 18 Mar 2005 21:06:09 -0000 1.4 *************** *** 12,15 **** --- 12,18 ---- * * $Log$ + * Revision 1.4 2005/03/18 21:06:09 dereksmithies + * Add help messages. Enable different flow control options. + * * Revision 1.3 2005/03/14 07:33:51 dereksmithies * Fix console input handling. Concatenate characters split by PSerialChannel reading. *************** *** 51,55 **** PINDEX stopBits; ! BOOL hardwareFlow; PINDEX hardwarePort; --- 54,58 ---- PINDEX stopBits; ! PString flowControlString; PINDEX hardwarePort; *************** *** 107,111 **** // Example command line is : ! // serial --hardwareport 0 --baud 4800 --parity odd --stopbits 1 --databits 8 --hardwareflow off args.Parse( --- 110,114 ---- // Example command line is : ! // serial --hardwareport 0 --baud 4800 --parity odd --stopbits 1 --databits 8 --flowcontrol XonXoff args.Parse( *************** *** 121,127 **** "-parity:" "-stopbits:" ! "-hardwareflow:" "-hardwareport:" ! "v-version" , FALSE); --- 124,131 ---- "-parity:" "-stopbits:" ! "-flowcontrol:" "-hardwareport:" ! "v-version." ! "h-help." , FALSE); *************** *** 150,153 **** --- 154,177 ---- #endif + if (args.HasOption('h')) { + cout << endl + #if PTRACING + << "-t --trace Debugging. Using more times for more detail" << endl + << "-o --output name of trace output file. If not specified, goes to stdout" << endl + #endif + #ifdef PMEMORY_CHECK + << " --setallocationbreakpoint stop program on allocation of memory block number" << endl + #endif + << " --baud Set the data rate for serial comms" << endl + << " --databits Set the number of data bits (5, 6, 7, 8)" << endl + << " --parity Set parity, even, odd or none " << endl + << " --stopbits Set the number of stop bits (0, 1, 2) " << endl + << " --flowcontrol Specifiy flow control, (none rtscts, xonxoff)" << endl + << " --hardwareport Which serial port to use, 0, 1, 2..." << endl + << "-v --version Print version information and exit" << endl + << "-h --help Write this help out. " << endl + << endl; + return; + } *************** *** 249,264 **** PString flow; ! if (!args.HasOption("hardwareflow")) { ! cout << "hardwareflow not specified. Hardware flow is set to off" << endl; ! flow = "off"; } else { ! flow = args.GetOptionString("hardwareflow"); ! cout << "hardwareflow is specified. Hardware flow is set to " << flow << endl; } ! if ((flow *= "on") || (flow *= "off")) ! hardwareFlow = (flow *= "on"); else { ! cout << "Valid args to hardware flow are on or off" << endl; return FALSE; } --- 273,288 ---- PString flow; ! if (!args.HasOption("flowcontrol")) { ! cout << "Flow control not specified. Flow control set to XonXoff" << endl; ! flow = "XonXoff"; } else { ! flow = args.GetOptionString("flowcontrol"); ! cout << "Flow control is specified. Flow control is set to " << flow << endl; } ! if ((flow *= "xonxoff") || (flow *= "rtscts") || (flow *= "none")) ! flowControlString = flow; else { ! cout << "Valid args to flowcontrol are \"XonXoff\" or \"RtsCts\" or \"none\"" << endl; return FALSE; } *************** *** 296,304 **** } ! PSerialChannel::FlowControl flowControl; ! if (hardwareFlow) ! flowControl = PSerialChannel::RtsCts; ! else flowControl = PSerialChannel::XonXoff; if (!serial.Open(portName, baud, dataBits, pValue, stopBits, flowControl, flowControl)) { --- 320,338 ---- } ! PSerialChannel::FlowControl flowControl = PSerialChannel::DefaultFlowControl; ! if (flowControlString *= "xonxoff"){ flowControl = PSerialChannel::XonXoff; + PTRACE(3, "Using xonxoff flow control"); + } + + if (flowControlString *= "rtscts") { + flowControl = PSerialChannel::RtsCts; + PTRACE(3, "Using rts cts flow conrol "); + } + + if (flowControlString *= "none") { + flowControl = PSerialChannel::NoFlowControl; + PTRACE(3, "Not using any flow control of any sort"); + } if (!serial.Open(portName, baud, dataBits, pValue, stopBits, flowControl, flowControl)) { |