Page 1 of 3

Error loading profile

PostPosted: Mon Mar 06, 2017 9:41 pm
by Ian
I've just started getting a Profile loading error; I can't say I've done anything unusual to cause it.

If I click on a Desktop linked profile I get a profile error,

Profile-error.jpg
Profile error

When the default profile is loaded I then try to load a profile from config. UCCNC then has to close.

UCCNC-stopped-working.jpg
UCCNC has to close

After a few tries, UCCNC loaded the desktop profile, so I made a new profile, and that also causes a "crash".

I've tried updating to 32, but it still persists.

Any Ideas anyone?

Ian

Re: Error loading profile

PostPosted: Mon Mar 06, 2017 9:47 pm
by cncdrive
Please post that profile file here to let me check.

Re: Error loading profile

PostPosted: Mon Mar 06, 2017 10:14 pm
by Ian
Ok thanks, no need to look tonight though!!

DM556.pro
(24.33 KiB) Downloaded 936 times

Re: Error loading profile

PostPosted: Mon Mar 06, 2017 11:01 pm
by cncdrive
OK, I have checked and the problem is that 2 keys' value are blank in your profile, these:

Spindleminvelocity=
Spindlemaxvelocity=

The keys are defined but have no value which is not allowed, because these are double (number) types.

The UCCNC can't write these keys blank, because writting the keys is done with a conversion from a numeric type, so it can't remain blank when the UCCNC writes these keys.
I suspect the HYPLUGIN.dll to write these keys blank, because I see that is the only plugin you have enabled in your profile and it is about the spindle, so I think it is probably writting these keys.

Re: Error loading profile

PostPosted: Tue Mar 07, 2017 2:07 pm
by Dan911
cncdrive wrote:OK, I have checked and the problem is that 2 keys' value are blank in your profile, these:

Spindleminvelocity=
Spindlemaxvelocity=

The keys are defined but have no value which is not allowed, because these are double (number) types.

The UCCNC can't write these keys blank, because writting the keys is done with a conversion from a numeric type, so it can't remain blank when the UCCNC writes these keys.
I suspect the HYPLUGIN.dll to write these keys blank, because I see that is the only plugin you have enabled in your profile and it is about the spindle, so I think it is probably writting these keys.


Yes, the HYplugin writes these only two values to the Pro file on "Shutdown_event()", Spindleminvelocity, Spindlemaxvelocity, Its there only for a convenience for the user. I have never seen this problem, is there something I can add to avoid this problem or should I just remove it? Possibly UCCNC shut down before finished writing?

Dan

Re: Error loading profile

PostPosted: Tue Mar 07, 2017 2:34 pm
by Dan911
After some thought I'm suspecting a Screenset/Profile change and UCCNC was restarted without a save from the HYPLUGIN configure window.

Re: Error loading profile

PostPosted: Tue Mar 07, 2017 3:50 pm
by cncdrive
Hi Dan,

Thank you for taking the time working on this.

So, I don't think the problem is that the UCCNC closes and that the write could not be finished, because the UCCNC writes the keys in a single instruction using a Windows API function.
We've implemented it this way exactly to make sure the key writting can't be interrupted.
This function is used:

[DllImport("KERNEL32.DLL", EntryPoint = "WritePrivateProfileSectionA", CharSet = CharSet.Ansi)]
private static extern int WritePrivateProfileSection(string lpAppName, string lpString, string lpFileName);

So, because it is a single instruction and the write instruction Flushes anyway, no matter if the application closed meanwhile, therefor there can be 2 possibilities:
1.) The write instruction is not called at all and then the key is not written.
2.) The write instruction was called and then the key is written properly.

Could you please check if you handling all possible user inputs properly and if you make any conversions about these values?
I mean isn't it possible that an exception happens when forexample the user typed in a non-number value when the exception is handled in a way that the string will become empty?

Re: Error loading profile

PostPosted: Wed Mar 08, 2017 12:10 am
by Dan911
Like I mentioned in previous post, these are the only files written to pro file, if its going to be a problem I will just remove.

public void Shutdown_event()
{
try
{
string minrpm = Properties.Settings.Default.selectedMinRpm;
string maxrpm = Properties.Settings.Default.selectedMaxRpm;

UC.Writekey("Spindlesetupsettings", "Spindleminvelocity", minrpm); //Save min rpm to pro file
UC.Writekey("Spindlesetupsettings", "Spindlemaxvelocity", maxrpm); //Save max rpm to pro file


}

catch (Exception) { }
}


I do have a check and will get a window in configure, but if its ignored than I guess it is possible to be saved null.


if (string.IsNullOrEmpty(MAXRPMtextBox.Text) && string.IsNullOrEmpty(MINRPMtextBox.Text))

{
MessageBox.Show("Must select a Max and Min RPM");
}

Re: Error loading profile

PostPosted: Wed Mar 08, 2017 12:51 am
by cncdrive
Hi Dan,

I think it would be even better to not even allow users to type in other than numbers if the textbox has to contain a number only.
Here is a little function for you which checks if the keys the user pressed are numeric characters and not allowing other characters to be inserted into the checkbox:

Code: Select all
private void Checkifnumber(object sender, KeyPressEventArgs e)
{
      if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.'))
      {
          e.Handled = true;
      }

     // only allow one decimal point
      if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
      {
          e.Handled = true;
      }
}


Just attach a Keypress Event to the textboxes of interest and call the above function.

Re: Error loading profile

PostPosted: Wed Mar 08, 2017 1:03 am
by Dan911
cncdrive wrote:Hi Dan,

I think it would be even better to not even allow users to type in other than numbers if the textbox has to contain a number only.
Here is a little function for you which checks if the keys the user pressed are numeric characters and not allowing other characters to be inserted into the checkbox:

Code: Select all
private void Checkifnumber(object sender, KeyPressEventArgs e)
{
      if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.'))
      {
          e.Handled = true;
      }

     // only allow one decimal point
      if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
      {
          e.Handled = true;
      }
}


Just attach a Keypress Event to the textboxes of interest and call the above function.


That's great and will do! I will also add a Null or empty check in the shut down event, if null or empty don't write.

Thanks,
Dan