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

Accessing Labjack (UE9) from different processes

UE9 ROS

  • Please log in to reply
8 replies to this topic

#1 francoisdt

francoisdt
  • Members
  • 12 posts

Posted 16 June 2015 - 06:00 AM

Hi, 

 

So I'm planning to using the Labjack UE9 together with ROS (Robot Operating System) which is basically a kind of framework allowing to create a software architecture made of different processes (called nodes) which can communicate with each other. This way, it allows to have for instance one node acquiring data from one kind of sensor, another acquiring data from another kind of sensor, and both sending data to a higher level process which can compute and send back a command to output. 

 

My question therefore is, is it possible to use the same Labjack from different processes? For example if I want to have one process acquiring distance sensor data, and another which outputs command for a motor, is it possible to do it, by sharing the labjack's handle between the processes (there is a way to do that easily with ROS)?

 

Or will I have to create a single process dedicated to communicating with the Labjack? That would be the least convenient option since I would then lose the modular side of the software architecture...



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 16 June 2015 - 10:47 AM

Are these actually different Windows Processes?  Or is ROS actually the O/S?  Are you using the UD driver for Windows, or direct TCP?  Is the T7 an option, or do you already have the UE9?



#3 francoisdt

francoisdt
  • Members
  • 12 posts

Posted 17 June 2015 - 12:17 AM

Sorry, I forgot to mention a few points. I'm operating under Linux, and ROS is not an actual OS (despite its name) but just C++ and python software tools and libraries. I already acquired the UE9, so th T7 isn't really an option anymore... And the aforementioned nodes are actual linux processes which communicates with each other by means of a ROS tool called "topics", similar to queued FIFOs.



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 17 June 2015 - 10:58 AM

Over USB you cannot share a handle between processes. Only one process at a time can have a USB handle to an individual LabJack. You can have the single dedicated process to handle communications as you mentioned or your processes will need to close your UE9's USB handle when the other process wants it.

 

As for TCP communications, you can have a couple TCP sockets open at a time so each process can have a socket open. Keep in mind that command/responses will not be process safe, so the command/response packets of one process might interfere with the others and for stability you will want to make your UE9 command/responses atomic between the processes.



#5 francoisdt

francoisdt
  • Members
  • 12 posts

Posted 18 June 2015 - 12:31 AM

I see, thank you for your answer. Out of curiosity, would it be easier with the T7? What would it change? 

 

 

 

for stability you will want to make your UE9 command/responses atomic between the processes.

 

What do you mean by atomic?



#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 18 June 2015 - 11:06 AM

In general I would recommend the T7 over the UE9 since it is a newer device with better hardware, features and software. However, in the case of multiple processes using the same T7 it runs into the same USB and TCP issues that the UE9 has, and my previous response will still apply. The multiple socket connections is a beta feature on the T7.

 

By atomic I mean one UE9 operation (command/response) at a time between the processes. I was using the computer science definition of atomic.



#7 francoisdt

francoisdt
  • Members
  • 12 posts

Posted 19 June 2015 - 01:09 AM

Okay, thank you for your answer. So, to sum up, the solution would be to either centralize all Labjacks operations in a single process, or find a way to make sure no other process is already sending command/receiving response from the labjack when trying to access it. 

 

I also read about LJFuse. Maybe it could be the right solution here? However I doubt it, since the problem of two processes trying to write/read the same file at the same time would still be there, plus it doesn't seems to support all Labjack's features like streaming data or use of timers...



#8 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 19 June 2015 - 10:50 AM

You could try using LJFuse and LJSocket which are multiple process safe in the sense that one command/response from one process will not interrupt one from another processes. LJFuse and LJSocket are the one process that open the device over USB and provide a file I/O or socket/TCP interface for other processes. They use LabJackPython whose command/responses are thread safe in its process. You can use timer/counters with them, but stream mode is not supported. Here's the LJFuse page for timer/counters:

 

http://labjack.com/s...ljfuse/advanced



#9 francoisdt

francoisdt
  • Members
  • 12 posts

Posted 22 June 2015 - 01:50 AM

I see thank you, I fear that I'll then have to gather all the labjack operations into a single process which will act a bit like a "medium-level driver" (if that makes sense), since I'd like to use the stream mode to get measurement from a parallax ping sensor as suggested here : https://forums.labja...?showtopic=4939

 

It's a shame because LJSocket looks like a good option to solve the problem. The Labjack would have to be plugged with USB though, which I'd like to avoid since using a direct ethernet connection would allow me not to embbed a computer dedicated to LJSocket. 

 

EDIT : I finally managed to get the ping sensor working without streaming, so maybe I'll try to implement LJSocket.





Also tagged with one or more of these keywords: UE9, ROS

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users