On Fri, Mar 5, 2010 at 2:12 PM, Chris Bagwell <ch...@cnpbagwell.com> wrote:
> Because your still seeing "bad magic" messages, I've got a concern > that we are throwing out packets that are related to going out of > proximity. If this occurs, we will never switch tools because for > case of pen to eraser, it will only make this decision on transition > from out of proximity to in proximity. That work around logic related > to side button seems to be related to why eraser to pen always works. > > It seems that in error cases, the current code is throwing away to > much data. It would be hard to ever get back in sync this way. Can > you search in wcmISDV4.c and look for this code: Upon further review, I think I was wrong about the wcmSerialValidate() consuming to much data.. but I think I see other issues. I think it would be safer to move this validation logic to earlier to prevent a case were a corrupt packet could be treated as a valid touch packet and consume wcmPktLength data; further corrupting next packet. /* Coordinate data bit check */ if (data[0] & 0x40) /* control data */ return common->wcmPktLength; else if ((n = wcmSerialValidate(common,data)) > 0) return n; Move right after: if (len < common->wcmPktLength) return 0; Also, it might be safer to rephase validation logic like this so we can verify the overall packet looks valid before we consume a full wcmPktLength worth of "control data". I'm assuming this "control data" follows same rules and has a 0x80 magic header with nothing else following it having 0x80. if ((n = wcmSerialValidate(common,data)) > 0) return n; /* Coordinate data bit check */ if (data[0] & 0x40) /* control data */ return common->wcmPktLength; Chris ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel