Dne Thu, 06 Dec 2012 10:16:01 +0100 Clinton Shane Wright <clintona...@gmail.com> napsal/-a:
> I am considering having the serData recieved write to a database > and process each thing stored into the database (or even a stringlist to > avoid extra problems or complications). After each input, you should determine of what kind of data you've received. At least you should distinct between solicited and unsoliticted data. Bellow is receiver handler from our SW originally developed in D1 at the very beginning of GSM era. Just for illustration, because it does not use synaser but asynchronous I/O. var Data: ANSIstring; Line: ANSIstring; CRidx: integer; begin if not Enabled then exit; Data := FRxTmpBuffer+RxDataFilter(Port.RxString); FRxTmpBuffer := sz; while Data<>sz do begin CRidx := pos(#13,Data); if CRidx<>0 then begin Line := copy(Data,1,CRidx-1); Data := copy(Data,CRidx+1,length(Data)-CRidx); IOCLog.Log(ThreadName,cmltInp,''''+Line+#13+''''); // continuous line of unsolicited data if FRxUnsolLines>0 then begin IOCLog.Log(ThreadName,cmltUns,'Unsolicited response'); __RxAddUnsolicited(Line); end // echo suppression else if CompareText(Line,FTxLastCommand)=0 then begin IOCLog.LogRsp(ThreadName,'echo, skipped'); end // Incoming voice indication (providing that there is a voice support) else if _RxDataRing(Line) then begin IOCLog.LogRsp(ThreadName,'ringing'); _Ringing; end // caller identification else if _RxDataVoice(Line) then begin IOCLog.LogRsp(ThreadName,'Voice data recognized'); end // unsolicited data, enqueue and signal them else if _RxDataUnsolicited(Line) then begin IOCLog.Log(ThreadName,cmltUns,'Unsolicited response'); __RxAddUnsolicited(Line); end // Ignored data e.g. RING has occured by voice support is disabled else if _RxDataIgnore(Line) then begin IOCLog.LogRsp(ThreadName,'ignored'); end // A command response else begin IOCLog.LogRsp(ThreadName,'response'); _RxAddResponse(Line); end; end // Prompt, which is not terminated by CR, e.g. '> '. It is converted to and handled as a response else if _RxDataPrompt(Data) then begin IOCLog.Log(ThreadName,cmltInp,''''+Data+''''); IOCLog.LogRsp(ThreadName,'prompt'); _RxAddResponse(Data); Data := sz; end // Remaining data fragment, keep it in the buffer temporary else begin FRxTmpBuffer := Data; Data := sz; end; end; end; ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ synalist-public mailing list synalist-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synalist-public