I saw Jeplers message on the linucCNC-devel IRC channel so I
though I would record it here since I noticed the bug.

This bug only affects one SSERIAL device in one mode so its not abig deal if 
not fixed for 2.5 release

In the SSERIAL driver, stream type data (and perhaps other data types) is 
converted to/from U32s for use as HAL pin data. The HAL pin data or SSERIAL 
data is masked with a created mask to drop any bits outside of the datasize 
range. This mask is created by left shifting a 1 by datasize, and then 
subtracting 1 from the result. This works fine up to 31 bits but fails at 32 
(the mask ends up being 0 instead of the expected 0xFFFFFFFF)

Here is a excerpt from autoconf.c that has the problem

  147   case 0x06: // byte stream
  148     buff = *pin->u32_pin & ((1 << conf->DataLength) - 1);
  149     break;

Heres are some good explanations of why this fails:

http://stackoverflow.com/questions/7401888/why-doesnt-left-bit-shift-for-32-bit-integers-work-as-expected-when-used

I patched it by making datasize 32 a special case (and didnt mask in this 
case), but theres probably a cleaner way.



Peter Wallace
Mesa Electronics

(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(")_(") signature to help him gain world domination.


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to