Author Topic: Wiimote Whiteboard software crashes when projector is connected  (Read 9996 times)

Offline Blanketman101

  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
hi!

I wrote my own version of Johnny Lee or Boon Jin's Wiimote Whiteboard software, using WiimoteLib 1.8 and C#. I just have a bit of an issue when connecting to the projector.

I've jsut been testing it on my own screen, without the projector, and it works fine. The problem is, when I connect the projector, the program crashes. Both run at the same resolution, and I clone the desktop (not extended).
It simply crashes at startup, saying the application has stopped working, and that a problem caused the program to stop working correctly.
It works if I connect it to my PC, but my laptop gives this issue.

Any ideas?

Thanks!



Offline boonjin

  • Moderator
  • *****
  • Posts: 929
  • Karma: +28/-0
  • Smoothboard Developer
    • View Profile
    • Smoothboard
Reply #1 on: September 21, 2011, 11:36:45 AM
Does Smoothboard work on your setup with the projector?

Regards,
Boon Jin

Smoothboard
Wii Whiteboard/Wiimote Whiteboard with annotation features and collaborate with multiple iPads and Android Tablets!

Smoothboard for Mac
Using a Mac? Now you can annotate on PowerPoint or Keynote slideshows!

BoonJin[/url


Offline Blanketman101

  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Reply #2 on: September 21, 2011, 04:47:12 PM
Thanks for the reply!

It does indeed work on the laptop, where my app just crashes at startup.
If I try to compile and run the code on the laptop, it compiles, and once it's done, just stops and nothing happens.



Offline Blanketman101

  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Reply #3 on: September 21, 2011, 05:16:31 PM
I checked the windows event log. Here's the error:

Application: Thistime.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
Stack:
   at System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control, System.Delegate, System.Object[], Boolean)
   at System.Windows.Forms.Control.Invoke(System.Delegate, System.Object[])
   at WindowsFormsApplication1.Form1.wm_WiimoteChanged(System.Object, WiimoteLib.WiimoteChangedEventArgs)
   at WiimoteLib.Wiimote.OnReadData(System.IAsyncResult)
   at System.IO.FileStream.AsyncFSCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)



Offline boonjin

  • Moderator
  • *****
  • Posts: 929
  • Karma: +28/-0
  • Smoothboard Developer
    • View Profile
    • Smoothboard
Reply #4 on: September 21, 2011, 07:52:03 PM
Maybe you can also post the code segment there the error occurs.

Regards,
Boon Jin

Smoothboard
Wii Whiteboard/Wiimote Whiteboard with annotation features and collaborate with multiple iPads and Android Tablets!

Smoothboard for Mac
Using a Mac? Now you can annotate on PowerPoint or Keynote slideshows!

BoonJin[/url


Offline Blanketman101

  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Reply #5 on: September 22, 2011, 06:30:46 AM
Hi

I'm not sure where it occurs. I've tried stepping through the program, but I can't find the code segment causing the crash.
I'm using visual C# express. Is there a way to find the code causing the crash? It gives me no crash report or error report. The compilation simply stops and visual express returns to itsnormal state.



Offline Blanketman101

  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Reply #6 on: September 25, 2011, 07:14:26 AM
Hi Boon

I just realised, app crashes at the

Application.Run(new Form1());

line of code. Any ideas? It still works perfectly  on my Desktop, but not on the laptop. Quite frustrating.



Offline boonjin

  • Moderator
  • *****
  • Posts: 929
  • Karma: +28/-0
  • Smoothboard Developer
    • View Profile
    • Smoothboard
Reply #7 on: September 25, 2011, 09:16:50 AM
You may want to take a look at the code at the constructor

Regards,
Boon Jin

Smoothboard
Wii Whiteboard/Wiimote Whiteboard with annotation features and collaborate with multiple iPads and Android Tablets!

Smoothboard for Mac
Using a Mac? Now you can annotate on PowerPoint or Keynote slideshows!

BoonJin[/url


Offline Blanketman101

  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Reply #8 on: September 25, 2011, 10:31:11 AM
Yes! I found the problem!

It was something completely different to what I expected. After I eventually stepped through almost every line of Code I found it. When I read from the txt file to get the previous calibration data, it crashes. I realised the problem occurs when I enter a for loop. Here's the code:

/*...previous code...*/

TextReader tr = new StreamReader("calibration_data.txt");
                string[] ListLines = new string[9];

                //Read the number of lines and put them in the array

                for (int i = 0; i < 8; i++)
                {
                    ListLines = tr.ReadLine();
                }

/*following code...*/

So it crashes when I enter that for loop for some reason. Now I just need to sort that out.

Thanks for the effort!!



Offline boonjin

  • Moderator
  • *****
  • Posts: 929
  • Karma: +28/-0
  • Smoothboard Developer
    • View Profile
    • Smoothboard
Reply #9 on: September 25, 2011, 08:33:58 PM
From your code, it seems that you are assuming that there are 8 lines in the calibration_data.txt file.

The file may not exist or do not contain the data.

If so, that may be the cause of the error.

Regards,
Boon Jin

Smoothboard
Wii Whiteboard/Wiimote Whiteboard with annotation features and collaborate with multiple iPads and Android Tablets!

Smoothboard for Mac
Using a Mac? Now you can annotate on PowerPoint or Keynote slideshows!

BoonJin[/url


Offline Blanketman101

  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Reply #10 on: September 26, 2011, 12:23:29 PM
The thing is, I create the txt file myself in another function, and it simply contains the coordinates of all 4 calibration points (x and y), thus 8 lines.
And this same code runs perfectly on my desktop. Its really hard to figure out what the issue is here. Here's the code of the whole function:

 public void read_calib_data()
        {
            // create reader & open file
            //TextReader tr = new StreamReader("calibration_data.txt");
            //string appPath = Path.GetDirectoryName(Application.ExecutablePath);

            if (File.Exists("calibration_data.txt"))
            {
                TextReader tr = new StreamReader("calibration_data.txt");
                string[] ListLines = new string[9];

                //Read the number of lines and put them in the array

                for (int i = 0; i < 8; i++)
                {
                    ListLines = tr.ReadLine();
                }

                tl_ir_point.X = Convert.ToInt16(ListLines[0]);
                tl_ir_point.Y = Convert.ToInt16(ListLines[1]);

                tr_ir_point.X = Convert.ToInt16(ListLines[2]);
                tr_ir_point.Y = Convert.ToInt16(ListLines[3]);

                br_ir_point.X = Convert.ToInt16(ListLines[4]);
                br_ir_point.Y = Convert.ToInt16(ListLines[5]);

                bl_ir_point.X = Convert.ToInt16(ListLines[6]);
                bl_ir_point.Y = Convert.ToInt16(ListLines[7]);
                               
               
                // close the stream
                tr.Close();
                already_calib = true;
                calib_done = true;
                CalibrationForm.busy_calib = false;
                CursorCtrl.calculate_constants();
                pictureBox1.Invalidate();
            }         
       
        }



Offline boonjin

  • Moderator
  • *****
  • Posts: 929
  • Karma: +28/-0
  • Smoothboard Developer
    • View Profile
    • Smoothboard
Reply #11 on: September 26, 2011, 09:53:28 PM
It can be that the file was not created on you laptop due to file access issues.

You may want to check whether the file exists.

Regards,
Boon jin

Smoothboard
Wii Whiteboard/Wiimote Whiteboard with annotation features and collaborate with multiple iPads and Android Tablets!

Smoothboard for Mac
Using a Mac? Now you can annotate on PowerPoint or Keynote slideshows!

BoonJin[/url


Offline Blanketman101

  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Reply #12 on: October 04, 2011, 02:38:28 AM
Hahaha sorry! I've finally found the problem! It was something completely different than what I expected!
I use a matrix library I found to calculate the 8 constants needed to traspose the IR-coordinates to screen coordinates. The function that calculates these constants is called right at the end of the data file read function. Somehow, this maths function crashes if I call it here, but if I call it at a later stage, there are no issues.
So weird.

Visual Express was a bit frustrating. As I stepped through my code it keeps crashing in different areas of the code, but always near to the place that causes the crash. This made it very hard to find the actual error.