Events

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #5597
    Author Image
    Kees Smit
    Participant

    Hi there,

    Once again a question about events. I built succesfully a class library with events for TouchSensor and ColorSensor. When used from within a Windows Forms Application it all works perfectly well as long as the application uses the events of only one sensor. When I want to use events of both sensors the application always stops with an “unknown error” exception. This error occurs on different lines of the event code (sometimes in the event code for TouchSensor, sometimes in code for ColorSensor.

    I hope someone can help me on this.

    In the attached zip-file is my test solution (VS 2015), containing the project for the class library (MonoBrickExtensionKSm) with events (EV3TouchSensorEvents and EV3ColorSensorEvents) and a project with a test application. There’s hardly no user-interface in the testapplication (just a form).
    First I thought it has something to do with the pollingthreads (to monitor the state of the sensors and call the events when necessary), but a test with no polling in one of the sensor events was no help, the exception still occurred. So I think the cause is somewhere else.

    To test:
    Build EV3-brick with Medium motor attached to port A, a Touchsensor to port2 and ColorSensor to port 1.
    In Form1.cs comment the code block at “Events for ColorSensor” to disable the use of EV3ColorSensorEvents. Run the application and when the from is visible you can stgart the motor by pressing the TouchSensor. The motor stops when releasing the sensor.
    Stop application and uncomment “Events for ColorSensor” and comment lines at “Events for TouchSensor”. Start application. Hold a white sheet of paper in front of the colorsensor to make sure it measures enough reflected light (it’s set to Reflection mode). When you remove the paper or cover the sensor, the measured light will be lower than the given treshold and the EV3-brick starts to beep. Put white paper in front of sensor again and the beeping stops. Close application when all works fine.
    Now, uncomment both code blocks and start the application. You will see the program stop with “Unknown error”.

    Any help is appriciated.

    Kind regards,
    Kees

    Attachments:
    You must be logged in to view attached files.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Posted in

Make a donation