USB Device - HIDAPI or ?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

darinkay
Posts: 4
Joined: Wed Aug 29, 2018 10:23 pm

USB Device - HIDAPI or ?

Post by darinkay » Wed Aug 29, 2018 10:42 pm

I searched the forum and did not find anything. Does anyone know how to communicate with a USB HID Device using LiveCode? I am specifically wanting to control a 16 channel relay that has a HID USB interface (no serial). I know the packet structure and I have it fully implemented in xojo using HIDAPI library (github: signal11/hidapi). I would also like to use this relay in conjunction with a LiveCode application I have but not really sure where to start. I assume there is a way to access the HIDAPI library from LiveCode but starting from scratch may be beyond my skill level. I guess there is not a huge demand for this or it would already exist but it would seem like a good thing to be able to do.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: USB Device - HIDAPI or ?

Post by bogs » Wed Aug 29, 2018 11:09 pm

I don't do much with USB devices, but I think Richmond and someone else were recently having a discussion about USB controllers, so maybe he'll stop in with some information about what your asking about.

*Edit - ah yes, this was the discussion I was thinking about :wink:
Image

darinkay
Posts: 4
Joined: Wed Aug 29, 2018 10:23 pm

Re: USB Device - HIDAPI or ?

Post by darinkay » Thu Sep 06, 2018 12:54 am

here is the relay I have if anyone has any insight
its a sainsmart 16-channel-usb-hid-programmable-control-relay-module
(i was going to post a link to it but apparently i can't)

I think I could have livecode execute some terminal commands through applescript to control it but that seems pretty clumsy

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: USB Device - HIDAPI or ?

Post by capellan » Thu Sep 06, 2018 4:32 am


darinkay
Posts: 4
Joined: Wed Aug 29, 2018 10:23 pm

Re: USB Device - HIDAPI or ?

Post by darinkay » Thu Sep 06, 2018 5:32 am

yes that is what I have, I am looking for anyone who know how to connect to an HID device with LiveCode, I have it implemented in XOJO and node.js so I know what the packet structure looks like, just need a hint of how to connect to it with LiveCode

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: USB Device - HIDAPI or ?

Post by capellan » Thu Sep 06, 2018 6:24 am

MaxV have posted an article about this some time ago:
http://livecodeitalia.blogspot.com/2014 ... ta_95.html

Here is a forum thread:
http://forums.livecode.com/viewtopic.ph ... hilit=xbee

and the Livecode API for these commands:
http://livecode.wikia.com/wiki/Read_from_driver

I do not have any device like the SainSmart to test this by myself. :|

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: USB Device - HIDAPI or ?

Post by capellan » Thu Sep 06, 2018 7:28 am

After following links from old mail list and forum messages, I found this reference:
https://www.bkohg.com/service/softwareX_e.html
The CD-ROM contains the Service-USB driver for Macintosh MacOS X, QuickTime films and screen shots as well as extensive software for AppleScript, Runtime Revolution, RealBasic, Xcode, 4th Dimension, FileMaker, MaxMSP, Java, Ragtime, Numbers, Scratch, DirectorMX, TCP/IP und der UNIX-Shell. Additionally there are original programs for various fischertechnik® construction kits.
in their webpage you could find a zipped folder (467kb) with many stacks that you need to check.
Runtime Revolution

This contains a project exclusively for the Service USB interface and Runtime Revolution's Revolution. All input and output functions and a stepping motor control example are implemented.

Additional stacks supports the fischertechnik Computing Starter Pack and the Industry Robots II Kit. The most up-to-date version of Revolution can be found on www.runrev.com.

Revolution.zip
BarCode Tester written by Sarah, could be useful too:
https://github.com/trozware/rev_stacks

After downloading these stacks and reading their scripts, tell us what you found useful for your project.

Al

darinkay
Posts: 4
Joined: Wed Aug 29, 2018 10:23 pm

Re: USB Device - HIDAPI or ?

Post by darinkay » Thu Sep 06, 2018 10:44 pm

Hi. Thanks for that information. This community is so willing to be helpful. Most of that looks to deal with a USB serial device, mine is HID (driverless) and in my research I haven't found a way to make MacOS recognize it as a serial device (I have tried extensively). But it looks like there is fairly decent support in LiveCode in going the VCP approach, so I'm going to order a USB serial relay and give it a try. I'll report back my results. Thanks!

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: USB Device - HIDAPI or ?

Post by capellan » Sun Sep 09, 2018 7:25 am

Hi Darinkay,

Polling devices constantly is commonly the function of drivers.
If a program do this function, Could be flagged as a threat by
the antivirus or another program?

https://en.wikipedia.org/wiki/Polling_( ... r_science)

Al

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: USB Device - HIDAPI or ?

Post by richmond62 » Sun Sep 09, 2018 1:15 pm

ah yes, this was the discussion I was thinking about
You are welcome to think as much as you like, but that discussion would do no good in this context.

As far as I can understand here, the poster wants to send commands FROM a LiveCode stack to a device via a USB connexion, as would MANY of us, but LiveCode central is about as helpful on this one as . . .

Personally, I have a collection of USB "tethered" floor robots that I should like kids to control from a LiveCode stack (instead of the prefabricated software supplied with them that does NOT work properly at all).

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: USB Device - HIDAPI or ?

Post by bogs » Sun Sep 09, 2018 2:05 pm

richmond62 wrote:
Sun Sep 09, 2018 1:15 pm
ah yes, this was the discussion I was thinking about
You are welcome to think as much as you like, but that discussion would do no good in this context.

As far as I can understand here, the poster wants to send commands FROM a LiveCode stack to a device via a USB connexion, as would MANY of us . . .
Granted, but before they can do that, they have to be able to see the device being read by the OS. The conversation I referred to was the only one I remembered it being discussed in, and even failure to achieve a goal is helpful, if for nothing else than to point out what was tried preventing you from having to repeat it :wink:
Image

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: USB Device - HIDAPI or ?

Post by PaulDaMacMan » Sat Feb 27, 2021 6:51 pm

Here I go with the zombie threads again...
I'm currently looking into building a LiveCode Builder wrapper for the cross platform HIDAPI library that was originally mentioned here.
If anyone is interested in helping that would be great. I'll probably upload to my GitHub repo once I have something actually
producing results other then returning the HIDAPI Library version number.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: USB Device - HIDAPI or ?

Post by richmond62 » Sun Feb 28, 2021 10:04 am

My "tethered" floor robots are still gathering dust in a cupboard . . .

Maybe they are slowly changing into zombies. 8)
Last edited by richmond62 on Fri Mar 19, 2021 11:58 am, edited 1 time in total.

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: USB Device - HIDAPI or ?

Post by simon.schvartzman » Sun Feb 28, 2021 6:35 pm

Hi PaulDaMacMan, I've never done anything involving libraries (except using them) but since I'm working on a project that is going to use an RFID reader with HID support I'm interested on what you are doing.

I'm not sure if I will be able to help but for sure I will try. Please let me know what can I do to start with

Regards
Simon
________________________________________
To ";" or not to ";" that is the question

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: USB Device - HIDAPI or ?

Post by PaulDaMacMan » Sun Feb 28, 2021 6:39 pm

So far just it logs some info on attached USB HID devices to the extension builder window. Testing on macOS 10.14.6.
https://github.com/PaulMcClernan/LCB_HIDAPI
*wchar_t is a problem, there's no 'sizeof' equivalent in LiveCode Builder to get the proper length.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply

Return to “Talking LiveCode”