USB communication with Python (Newport Instrument) - dll

I´m currently trying to make USB communication to the laser controler TLB 6700 (New Focus - Newport) with python.
https://www.newport.com/f/velocity-wide-&-fine-tunable-lasers
This is my first python task, and I´ve been having several troubles. So, by steps:
1) This device has its own drivers, and a comercial software to control it. However, I would like to develop my own code to perform several automation procedures.
2) The newport drivers are not NI compatible. This mean that I can not use PyVisa to recognise the device if I´m using the Newport drivers.
3) I think I can not use PyUSB too, for the same reasson. Even I´m not totally sure about that.
4) A solution that I´ve found is to use the NI-Interactive control to install a secondary NI driver for the device. Following this procedure I can recognise the device with PyUSB.
5) However, I do not understand how to activate the device and to send commands. I guess that the correct procedure is something like:
5.1: Call a library. Newport provides diferent libraries and dllwrapers. I´m asuming that the correct procedure is to use Ctypes to call the primary device dll. This will lead the possible instruction call.
5.2: Recognise the device as I´ve done with the NI driver and thorugh PyUSB.
5.3: Open the device and send command through PyUSB code.
So, here my questions:
PyVISA seems much easier to use than PyUSB. Any of you know a procedure to do the same but with PyVISA?
Any of you have done similar procedure with Newport devices, or even with the same TLB 6700 controller?
Thank you in advance,
Cheers,

It might be a bit late but just in case, I developed a python code to control a TLB 67xx. You could find it in my github.
Basically I call the dll through (UsbDllWrap) python net (import clr) and use it to set the wavelength, start a scan , etc... I do have several decorator that you could dismiss (#InOut.output for instance). You might need to adjust the path of your dll, if you do not use Anaconda for python. That is the only decent way I found to control the NewFocus laser, as it will not be possible to control them through PyVisa.
Obviously, doing so it is only possible on Windows.
I am still working on a cross platform solution that could be suitable for Linux

Related

Talk to an USB HID device from within GNU Octave

I need to control a measurement instrument from within GNU Octave. The instrument has an USB HID interface. I just need to read or change the settings of the instrument. It's not about getting measurement data from the instrument.
What options are there to do this from within GNU Octave, and how do they work?
The simplest approach would be to use an already made Octave package (like the instrument-control package). Then you could check the documentation and read /write to and from a USB device.
The package linked above (and here again) has a USB TMC set of functions if the USB device works with this library. See the function list to find out how to use the package. As far as I am aware this package only works on Linux for USBTMC (according to the wiki).
Otherwise if you are not running Linux, or the device is not supported, I cannot specifically see any other already-written set of Octave functions for communication.
However, if you have the time it could be worth writing just a singular MEX (C/C++) function to open the communication channel and read settings from the device.
You could then make this work on Windows as well. Most of this functionality is already implemented in libraries such as signal11 (just to name one...), which that library itself is already cross-platform. Using that library inparticular makes it look like a very short MEX file to write.
I hope this helps and check out the links for further information about the topics discussed :)

Controlling Nikon camera with MTP

I was wondering how i would be able to get started with controlling my nikon DSLR camera? I have been reading on the Nikon SDK and MPT/PTP and is really confused on how to start with writing a script to control it. Thanks for helping me.
If you are just wanting to script stuff, under Linux libgphoto2 and gphoto2 are a good start.
You can use them under windows, I'm not sure if there are pre-compiled build available, but that would also require installing the USB wrapper libraries, and that a touch fiddly.
The next step above that is to compile libgphoto2 in cygwin (there are some good guides how to this on the web), but that overkill.
I am currently using digicamcontrol in windows, and for Nikon and C# code it's really nice to use, and very fast, plus it has no hassle on the USB front. It wouldn't be too hard to write a small C# that does what you want (unknown) and then run that from scripts.
this is what you are looking for:
http://sourceforge.net/projects/nikoncswrapper/
Good luck
In case anybody is still looking at this: the answer is a bit more complex if what you are looking to do is write your own code to access a Nikon DSLR. Thomas Dideriksen's SDK wrapper referenced above is great in making it easy to access Nikon's SDK to control almost all camera functions - but it is restricted to USB-cable access since that SDK does not support wireless access. If the latter is what you want, your best option may be Duka Istvan's digiCamControl, which Simeon suggests above. This open-source C# project can be used as a standalone library. (See the development documentation page.) It is not all that well documented, though, so figuring out how to control all camera parameters can be tricky.

How can I debug a USB HID device that does not come with a driver?

I have a single button USB controller, but it did not come with any drivers (simply a Windows program that communicates with it directly for its intended purpose).
USB Fidget
Vendor ID: 0x1d34
Product ID: 0x0001
Product name: DL100A Dream Cheeky Generic Controller
So, I would like to be able to read whether or not the button is being pressed. My main development environment is Mac, but I'd like the solution to run on Windows too. So ideally a cross platform solution would be best.
I can find pieces of code for other devices by the same manufacturer but there are differences in Product ID so the code does not work and I lack understanding to change anything other than the vendor/product.
As far as I understand it I need to poll the USB device with a feature request packet?
Is there some software I can use to "watch" the USB device so I can see what is actually happening when I press the button? If not, how would I go about writing some myself?
basically on MacOs very huge amount of usb devices work through IOUserClient. This standart class provide to user mode programs ability to control device without kernel mode driver (by using usermode part of IOKit framework). To sniff for usb packets you can use USB Prober, start from this article http://developer.apple.com/library/mac/#qa/qa1370/_index.html
On windows standart way - standart USB driver + standart HID driver, no need in specific vendor driver if they not develop some additional functionality over standart. You can use any of commercial or freeware tools to sniff usb packets - like this one http://www.hhdsoftware.com/usb-monitor
I don't know of any cross platform way to handle it. This is the presentation I point people to for how to create a driver app for a random piece of HID hardware:
https://developer.apple.com/videos/wwdc/2011/?id=207
For testing / accessing HID devices, i.e.
Get Feature Report (matt's original question)
Sending Feature Reports
Sending Output Reports
Receiving Input reports
I'd suggest the "HIDAPI Test Tool" / "testgui" included in the great cross-platform HID library from signal11/hidapi.
On Windows you require an additional 3rd party package to compile the testgui application, but it was pretty easy and the GUI tool was more straightforward that other code examples and tools I saw. (I could cross-check if I am maybe allowed to publish a VS2008 compiled version of this.)
Another free option for sending output reports and receiving input reports, is our own "Docklight" tool (in evaluation mode, unlimited time, just no storing), see Docklight Scripting HID USB.

Playstation Eye with Labiew

Does anyone know how to integrate the Playstation Eye with Labview? Can a driver somehow be used to allow Labview to recognize it as a webcam?
You should be able to do this with vision (install IMAQdx and Vision Dev Module)- it seems to be DirectShow, which IMAQ can do- or try out the code found on this page: http://www.labviewforum.de/thread-21279.html - it uses the original dlls.
as there are NO official dll´s for the PS3 Eye on Windows, the ONLY Option is to use the 3rd Party drivers from Code Laboratries or directly interface the Hardware via USB-RAW commands. Code Laboratries PS3 Implementation however does not seem to be 100% conform with the Direct Show standard. You can get a PS3 Eye to work with Labview (via Direct Show and IMAQ), but you will be limited by the usable framerates.
I tried to interface the dll from code laboratries directly, but got stuck on a stange error with the second function i tried (see the already referenced Thread http://www.labviewforum.de/thread-21279.html). However it seems as for now there is a Vi Package available for the PS3 Eye to support LabView under OSX with the full available framerate. More Information can be found here:
http://labview.epfl.ch/
Hope this helps.
Best Regards,
Jan

Qt Mobile broadcasting (DVB-H) API

I want to create a Qt program that uses the DVB-H headset to watch and record programs. I know there is already such a program on the Nokia store but it doesn't work with latest headset. I have already found this http://library.developer.nokia.com/index.jsptopic=/Java_Developers_Library/GUID-154101B4-1539-4025-9698-FC1FBF393C0E.html for using the headset with a Java app, but I want to know if there is a Qt version of this API that I can use. I have been looking around but I can't find one, maybe there isn't one. If you know anything about this please help.
Qt APIs for DVB-H do not exist. JSR-272 is the only option on Symbian.