Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

invalid handle & proper error handling

error handle

  • Please log in to reply
6 replies to this topic

#1 ElectroLund

ElectroLund
  • Members
  • 14 posts

Posted 07 May 2014 - 08:49 AM

Hi, I'm using a U3 with latest firmware in a project, developing with NI LabWindows / CVI.  Everything is working well.

 

My only issue is with error handling.  I'm using the string function ErrorToString to decode the error numbers.  It works fine.  However, I have noticed that when I "pull the plug" of the LabJack during use, the errors I always get are a "invalid handle" rather than what I would expect: "labjack not found". 

 

 

Regardless, to attempt to recover from these kinds of big errors, I attempt a ResetLabJack() but that doesn't seem to work either.

 

Any thoughts on this?

 



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 07 May 2014 - 03:13 PM

What version of LabJackUD are you using? GetDriverVersion() should tell you that.  In current versions when the U3 is no logger connected you should be getting a LJE_DEVICE_NOT_CONNECTED (error 1015) error after successfully communicating with a U3 and then unplugging it. 

When you reattach the U3, the handle should work properly for that U3, assuming it is the same.  You shouldn't have to call ResetLabJack() or anything else.

 

Would it be possible for you to send us your code?   Some more info about how you are opening the U3, etc would help us troubleshoot this.  For instance, if you open a U3, then create a simple loop that only reads an analog input every 5 seconds and prints it to the screen (or an error if you get one), you should see the proper values, then once the U3 is unplugged error 1015, then when it is reattached it should start reporting the correct values again.



#3 ElectroLund

ElectroLund
  • Members
  • 14 posts

Posted 08 May 2014 - 05:32 AM

My LabjJackUD.h header:

#define DRIVER_VERSION 3.42 

I'll do some testing today.  In the meantime, I'm going to PM you some code snippets...



#4 ElectroLund

ElectroLund
  • Members
  • 14 posts

Posted 08 May 2014 - 05:36 AM

Well strike that, I'm not seeing that PM'ing is enabled on this board.  Ok, where do I send my files?  :)



#5 ElectroLund

ElectroLund
  • Members
  • 14 posts

Posted 08 May 2014 - 06:56 AM

I have a little more info, but not much.  In another identical test, I yanked the USB cable from my LabJack mid-test and observed.  Immediately I got error 1008 ("Communications error.").  The caller in this first case was a digital input request to the LabJack.  So far, so good. 

 

When I plug the LabJack back in, it does in fact re-establish comms by itself.  All those digital inputs and outputs continue working again.

 

However, I have one a periodic timer input capture on another LabJack pin.  After reconnecting the U3, this function is unhappy.  I get error 43 ("Timer Share Error").  Doing the ResetLabJack() function doesn't fix this.  Do I need to reinit the LabJack IO?



#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 08 May 2014 - 07:30 AM

Attach files here or send to [email protected] and reference this topic.

 

If you have to do some timer configuration in your program, then a device reset will put the device back in the default state.  You either have to re-do the configuration in your software, or use "Config Defaults" in LJControlPanel to make your desired configuration the power-up default.



#7 ElectroLund

ElectroLund
  • Members
  • 14 posts

Posted 08 May 2014 - 09:52 AM

Gotcha.  I attempted this, but I was getting some General Protection Faults.  So I merely did some delaying between the ResetLabJack call and my Init function.  Now, all is well again, without errors and my timer works after re-init.

 

Thanks!





Also tagged with one or more of these keywords: error, handle

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users