Error loading profile

If you have a question about the software please ask it here.

Error loading profile

Postby Ian » Mon Mar 06, 2017 9:41 pm

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
Ian
 
Posts: 7
Joined: Sat Feb 11, 2017 2:55 pm
Location: Switzerland

Re: Error loading profile

Postby cncdrive » Mon Mar 06, 2017 9:47 pm

Please post that profile file here to let me check.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Error loading profile

Postby Ian » Mon Mar 06, 2017 10:14 pm

Ok thanks, no need to look tonight though!!

DM556.pro
(24.33 KiB) Downloaded 936 times
Ian
 
Posts: 7
Joined: Sat Feb 11, 2017 2:55 pm
Location: Switzerland

Re: Error loading profile

Postby cncdrive » Mon Mar 06, 2017 11:01 pm

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.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Error loading profile

Postby Dan911 » Tue Mar 07, 2017 2:07 pm

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
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Error loading profile

Postby Dan911 » Tue Mar 07, 2017 2:34 pm

After some thought I'm suspecting a Screenset/Profile change and UCCNC was restarted without a save from the HYPLUGIN configure window.
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Error loading profile

Postby cncdrive » Tue Mar 07, 2017 3:50 pm

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?
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Error loading profile

Postby Dan911 » Wed Mar 08, 2017 12:10 am

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");
}
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Error loading profile

Postby cncdrive » Wed Mar 08, 2017 12:51 am

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.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Error loading profile

Postby Dan911 » Wed Mar 08, 2017 1:03 am

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
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Next

Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 19 guests