Page 1 of 1

Encoder_simple vs Encoder_full, C#

Posted: Wed Jan 06, 2016 11:01 pm
by Bryan_sang

In 2012, I've been running almost flawlessly HighSpeedEncoder by using Encoder_simple for monitoring on the console and saving the data as text format file.
In the meantime, I did not have a chance to run the program.

In December 2015, I have updated the phidgets c# program, since I am using the program for other purposes also. With Encoder-full, allowing form-based monitoring, I do not have any problem at all. However, when I run the Encoder_simple, almost always, the program issues error message, even if the console says it acknowledges my HighSpeedEncoder 1057_1.

ErrorType: clr20r3 P1: encoder-simple.exe P2:
p3: 4efd467e p4: P5: P6 : 572e67d
p7: 473 P8: 1b P9: phidgets.phidgetexception

Exception Information
Code: 0xe0434f4d

System Information
Windows NT 5.1 Build: 2600

By the way, I have an old PC running WindowsXP, with a Pentium CPU.

--P.S.: I have almost the same symptom even with new PC's, running Windows7, i5, or Windows 8.1, i7 CPU.

Thanks in advance,


Re: Encoder_simple vs Encoder_full, C#

Posted: Thu Jan 07, 2016 10:51 am
by Patrick

This is because the Time property from the position change event can throw an exception on the first event - when the time isn't yet known.

You can fix the example by putting a try-catch block around the accessor like so:

Code: Select all

        static void encoder_PositionChange(object sender, EncoderPositionChangeEventArgs e)
                Console.WriteLine("Encoder {0} Change {1} Time {2} Position {3}", e.Index,
                                       e.PositionChange, e.Time, encoder.encoders[e.Index]);
            catch { }

The library really shouldn't be throwing an exception on an event property like this, so I'll remove that behaviour in the library.


Re: Encoder_simple vs Encoder_full, C#

Posted: Sun Jan 17, 2016 6:22 pm
by Bryan_sang
Dear Patrick,

Thanks for the kind reply to this problem.
I'll give it a try.

Bryan :D