HomeGenie Forum

General Category => Troubleshooting and Support => Topic started by: ocalvo on February 24, 2015, 07:54:37 AM

Title: Debug logging
Post by: ocalvo on February 24, 2015, 07:54:37 AM
I am struggling to get Insteon working. I have turned on logging but the generated logs does not have usefull data.

Is there a "debug level" I can turn on?

Thanks,

Oscar
Title: Re: Debug logging
Post by: nolio on February 24, 2015, 12:38:19 PM
You can launch HG program in command line from the HG directory.
Title: Re: Debug logging
Post by: Gene on February 24, 2015, 02:58:50 PM
Hi ocalvo,

the best option to debug is doing it from source code.
To see why your modules aren't listed add a break point here:

https://github.com/genielabs/HomeGenie/blob/master/MigFiles/MIG/Interfaces/HomeAutomation/Insteon.cs#L176

If then you get familiar with debugging and hg, perhaps you can help adding missing code for handling incoming insteon events:

https://github.com/genielabs/HomeGenie/blob/master/MigFiles/MIG/Interfaces/HomeAutomation/Insteon.cs#L237

Cheers,
g.
Title: Re: Debug logging
Post by: ocalvo on February 25, 2015, 07:49:39 AM
I am getting this output from console:
PLM ERROR: Access to the port 'COM3' is denied.
PLM ERROR: Object reference not set to an instance of an object.
PLM ERROR: Access to the port 'COM3' is denied.
PLM ERROR: Access to the port 'COM3' is denied.
PLM ERROR: Access to the port 'COM3' is denied.
PLM ERROR: Access to the port 'COM3' is denied.


My little test program works fine. Dont know why HomeGenie does not have access to it.
Title: Re: Debug logging
Post by: ocalvo on February 25, 2015, 08:54:00 AM
I debug a little more:

The Disconnect method is calling Thread.Abort(). If the Plm was inside the Receive method, this will render the COM port opened and the program itself will no longer be able to connect

In general calling Thread.Abort should NEVER be called. Instead I propose that you start a new Task using Task.Start and pass a cancellation token. When Disconnect is called, then call CancellationTokenSource.Cancel to cancel the task gracefully.

I can provide a fix for this. Will try to submit a push request later.