On 22/03/16 21:56, Andy Carter wrote: > On Monday 21 Mar 2016 22:27:21 Johan Ström wrote: >> I'm quite sure the error is at ow_parseinput.c line 462: >> >> // shorten the buffer length by the comma and discarded chars >> end -= entry_length - allowed_length - 1 ; >> >> The purpose is to move the endpointer, but the logic is wrong, and the >> last element length (line 441) is wrongly calculated base on 'end'. >> My currently tired brain suggests 'end -= entry_length - 1;', but I >> might be wrong.. And I do not have any device at all which accepts an >> aggregate ascii write. > I've been looking at this section a lot today - then going away to clear my > head! > > The first three lines display OK and the debug shows padding to these with > 0x20 > bytes > <.aaa > > > The last line displays the expected string but with the last char repeated > (ddd sent), then a series of 0x00 double-pipes before a series of 0x20 > <Tdddd..... > > > It looks to my simple mind that the problem lies within the line 440 > > if (extension == elements - 1) { // last element > entry_length = end - buffer_position ; > .. > } > > statement. Changing this to > > if (extension == elements - 1) { // last element > entry_length = end - buffer_position - element - 1 ; > .. > } > > gets rid of the 0x00 bytes and gives good results (with limited testing so > far) - but I still see the last char repeated and I have no idea at all where > that is coming from > > Any thoughts?
My theory is, the buffer begins as "aaa,bbb,ccc,ddd". After each iteration, it does memmove and trims away the comma (moves rest of string down 1 byte). That is, "bbb,ccc,ddd" is moved 1 byte earlier. But it does not overwrite the data behind the "end". Result: 0 round: aaa,bbb,ccc,ddd\0 1 round: aaabbb,ccc,dddd\0 2 round: aaabbbccc,dddd\0\0 3 round: aaabbbcccdddd\0\0\0 The first three elements are get's their length properly (3). But the last one gets wrong length, instead of 3 it gets 6... Well, that doesn't really match what you describe either..so.. To nail this properly, I'm going to try to write some unittests for this, so it is reproducible and works for all side-cases (wrong lengths etc). As for your offer on an LCD, if we don't manage to nail it by writing proper tests for it, we might go that way. But I'd probably not use it IRL anyway, so would be a bit waste.. if we get it to work otherwise, that is :) Johan ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140 _______________________________________________ Owfs-developers mailing list Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers