Instrument Control (GPIB, Serial, VISA, IVI)

Showing results for 
Search instead for 
Did you mean: 

LabJack Unable to Write to I2C Device

Go to solution

Hello Everyone, Thank you in advanced for your time! 


I am trying to use a U3 LabJack in order to control a MCP23017 I2C device. I am much more comfortable in C# than TestStand so I wanted to keep the vast majority of the logic and commands in C#. 


Right now I have multiple classes that create and control the LabJack and I2C device, if I use a main in order to control the classes there is no error and the relays I specify are flipped on the I2C device. But when I build it to a class library and try to run the same commands in TestStand instead of using a static main I get a very strange error. I even just made the main not static and tried to run that in TestStand so no variables where being passed in and I got the error at the same exact spot as I did when trying calling the commands one at a time.


The error is in an attached image LJI2CError.png

A picture of the main is also attached Main.png


To be more clear -- My program runs correctly when I use pure C#, when I try to run the same exact file in TestStand I get an error. 


Quick Summary of Solutions I have tried 

- Making sure my DLL is built correctly according to the TestStand 2020 x64 specs. 

- Calling the commands one at a time and saving the various objects in local object references and passing them in when required. 

- Putting waits/pauses in my code between commands 

- I tried to run the NI Example IC2 Code (can be found in "DotNet_LJUD\Examples\LJUDDotNet\U3\C#\U3_I2C") I was able to get it running in C# but again when I tried to run it using TestStand I got the same exact issue in the same spot 

- I am not sure if this helps but I also found some information on potential the same or similar error, Error Number: 478779,  TestStand 2019 Known Issues By Date - NI


I know this might be a long shot but I would really appreciate any help or explanation, Thank you! 

Download All
0 Kudos
Message 1 of 3
Accepted by topic author wyntre

The Error is likely due to the application bitness and usage of AddRequest. AddRequest expects a 32-bit integer for x1. This is a problem if you are running a 64-bit app and need to make calls where you pass an array (reference) to the x1 parameter. Instead, please replace AddRequest with AddRequestPtr wherever you need to pass an array to x1, such as with the I2C write command:

Message 2 of 3

It Worked! Thank you! 


Needless to say I am very grateful and appreciate your time and effort. 



0 Kudos
Message 3 of 3