[Mono-dev] Patch for System.IO.Ports.SerialPort ReadLinefunction

Michael Mattess MichaelMattess at rauland.com.au
Mon Nov 5 20:56:55 EST 2007


Hello Miguel,

 

Yes using the ReadTo function does make the most sense as it is a special case of the operation.

 

I had a look at the ReadTo function and I think it is broken.  It assumes that it is in the initial state (IE current is 0) when it encounters the beginning of the string it is reading to.  So if we are reading to "ababZ" and the input is "abababZfoo" it will read past the "ababZ".  

 

It was because of this that I put the 'state-driven' approach into the too hard / too complex basket when I wrote my initial function.  But thinking about it further the ReadTo function could be extended to keep multiple states (ie a list of 'current' offsets).  One for each time a potential beginning of the string we are looking for is encountered.  I have attached a file with such an extended ReadTo function.

 

 Let me know your thought.

 

Regards

Michael

 

 


________________________________

From: Miguel de Icaza [mailto:miguel at novell.com]
Sent: Tue 06.11.2007 02:06
To: Michael Mattess
Cc: mono-devel-list at lists.ximian.com
Subject: Re: [Mono-dev] Patch for System.IO.Ports.SerialPort ReadLinefunction



Hello,

    My ReadLine routine is broken, it did not append data that was only
partially part of the ReadLine.   While I was fixing it, I noticed that
we already have a routine that did this correctly (ReadTo).

    So am going to just change the code to be:

        ReadTo (new_line).

Miguel.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071106/b8e46c4f/attachment.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ReadToFunction.txt
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071106/b8e46c4f/attachment.txt 


More information about the Mono-devel-list mailing list