From: David G. <dav...@ro...> - 2015-02-08 22:23:45
|
Clint, Indeed I am running on Windows and there is a control-z (SUB - silly mnemonic) in the middle of the line. David From: "Jeffery, Clint (jef...@ui...)" <jef...@ui...> To: Jafar Al-Gharaibeh <to....@gm...>; "dav...@ro..." <dav...@ro...>; Bruce & Breeanna Rennie <br...@dc...>; "uni...@li..." <uni...@li...> Sent: Sunday, February 8, 2015 1:15 PM Subject: Re: [Unicon-group] open(file, r (vs) ru) and premature end of file on read() The most likely culprit would be a control-D on unix or control-Z for DOS. Binary mode sure sounds like a DOS concept, doesn't it? Give us a small sample that demonstrates and we will look into it but it may be the C library or the OS. -------- Original message -------- From: Jafar Al-Gharaibeh <to....@gm...> Date: 02/08/2015 7:37 AM (GMT-08:00) To: dav...@ro...,Bruce & Breeanna Rennie <br...@dc...>,uni...@li... Subject: Re: [Unicon-group] open(file, r (vs) ru) and premature end of file on read() David, I have seen this behavior in a program copying a few files, one of them was a little image. Only a few bytes were being copied in the image file, upto to a byte that was being translated as EOF. As Bruce advised, for binary data you want to use the "u" mode to make sure you are always getting untranslated data. I learned my lesson! :-)--Jafar On Sun, Feb 8, 2015, 9:15 AM null <dav...@ro...> wrote: Bruce, The data us correct for parity. It was captured by a device that is essentially a serial sniffer The record causing the problem was further decoded from the original stream and generated by my first filter. The question, and I will come back to look at it more once I get what I need from the second filter, is why did read prematurely stop reading the file. The file is over 9k records and read stops after just over 100. It suggests that a sequence of binary characters in a file means end of file to read unless it's opened ru. David Sent from my BlackBerry 10 smartphone on the Rogers network. Original Message From: Bruce & Breeanna Rennie Sent: Sunday, February 8, 2015 1:45 AM To: uni...@li... Subject: Re: [Unicon-group] open(file, r (vs) ru) and premature end of file on read() Good afternoon David, The fact that you are reading data that came from a serial connection, I would check what the data and parity of the connection is first. In any case, I would always advise that you open with "ru" on any communications line (serial) as. One can never assume that any communications line will have sensible information in terms of characters coming down it. Early in my career,I and my colleagues wrote communications programs in COBOL and in doing so, we saw "interesting" bit streams crossing the communication lines. In a number of cases, we had to use line analysers to determine how we should interpret the data. regards Bruce Rennie On 08/02/15 05:17, David Gamey wrote: > Hi Folks, > > I needed to add some logic to data filter I was working with. I chose > to write a separate test version to process the output of the first > filter with the idea of combining them later. And then I hit a > strange result. > > * The original data was a trace of a serial connection, so lots of > STX, ETX, NUL, etc. > * The original filter opened the files with "r" and "w" modes. It > appeared to operate fine. > * The test filter originally also opened the files the same way. > > I was surprised that the filter stopped reading about 1% of the way > through the file as if it hit end of file. The line following the last > read was synthesized by the filter and not in the original trace - so > I think that line is the cause. > > Needless to say I was a bit surprised and perturbed. > > I can bypass this by opening with "ru" so I am fine for now. I'll also > go back and fix the original filter (but I don't think it was a > problem in the original file). > > _The question that I wanted to pose was what is causing read to fail > before the actual end of file?_ > > David > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming. The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net/ > > > _______________________________________________ > Unicon-group mailing list > Uni...@li... > https://lists.sourceforge.net/lists/listinfo/unicon-group ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Unicon-group mailing list Uni...@li... https://lists.sourceforge.net/lists/listinfo/unicon-group ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Unicon-group mailing list Uni...@li... https://lists.sourceforge.net/lists/listinfo/unicon-group ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Unicon-group mailing list Uni...@li... https://lists.sourceforge.net/lists/listinfo/unicon-group |