Page 1 of 2
Controlling an external device
Posted: Sat Mar 14, 2015 8:49 pm
by richmond62
So, I have an API key for an external device,
and I load the API key into a textField . . .
BUT, I need to send commands to the external device like this:
string Send(string group, string command, string arguments);
???????????????????????????????
Re: Controlling an external device
Posted: Sat Mar 14, 2015 9:42 pm
by dunbarx
Richmond.
I have played around with external gadgets forever. What sort of thing are you trying to talk to?
Craig
Re: Controlling an external device
Posted: Sat Mar 14, 2015 11:37 pm
by richmond62
Re: Controlling an external device
Posted: Sun Mar 15, 2015 1:43 pm
by richmond62
This is almost as easy as the reverse:
https://www.youtube.com/watch?v=8HoBia1WLXk
I'm not sure why getting data OUT of a LiveCode to a device connected to a PC via USB or somesuch seems more difficult.
Re: Controlling an external device
Posted: Sun Mar 15, 2015 5:23 pm
by dunbarx
Richmond.
Check out
http://www.bkohg.com
The "USB Service Plus" or any of its smaller brothers. Not inexpensive, but so LC-like and accessible.
On another note, how is your waste pump replacement project going?
Craig
Re: Controlling an external device
Posted: Sun Mar 15, 2015 5:29 pm
by richmond62
Thanks, Craig,
The waste-pump was just by way of illustration: as, in a house it is almost as easy to get the
sh** out and to get the sh** in the toilet.
Re: Controlling an external device
Posted: Sun Mar 15, 2015 5:52 pm
by richmond62
I must be very stupid, but I cannot understand why it is necessary to have another bit of hardware
between the USB device one wants to control and one's computer.
These devices seem to be simply converters from various other connectors to USB.
This completely misses the point of my question.
So, I shall rephrase my question:
Imagine a scenario where I have a USB device jacked into one of the USB ports on my computer.
I wish to send commands to that device using Livecode without any intermediate hardware
or an command-prompt stuff and anything else that is dependent on the OS.
Many long years ago, I had a turtle tethered to a BBC Master Micro Compact via some
outmoded and forgotten connector.
It could be addressed and told to wander around on a bit of wallpaper (it held a ballpoint pen)
and draw spirograph pictures using BBC BASIC.
That is the sort of thing I should like tobuild in LiveCode: a front-end for manipulating
this, supposedly modernised, turtle.
https://roamernews.wordpress.com/introducing-roamer/
Re: Controlling an external device
Posted: Sun Mar 15, 2015 7:49 pm
by richmond62
Poking around in the documentation I found:
which looks groovy . . .
until you realise that, somehow, your front-end has to auto-detect the USB device AND
. . . "the name of a device driver that's installed on the system" . . . which is a problem
as very many USB devices DON'T have drivers (especially on Macintosh and Linux!!!!!).
NOW, my "problem" is that I want to help some wee bairn who plugs in his/her 'turtle'

- tortoise.jpg (6.03 KiB) Viewed 9073 times
to any old USB socket on his/her machine, or on a USB hub attached to the machine
and be able to control the blasted thing: BACK, FORWARDS, LEFT-TURN, RIGHT-TURN, TRAVEL,
PEN DOWN, PEN UP and so on.
Re: Controlling an external device
Posted: Sun Mar 15, 2015 8:28 pm
by dunbarx
Richmond.
Somewhere, perhaps in the device, there must be a framework that can connect to and understand the I/O commands and functions that LC is talking about. In the gadget I mentioned, this framework is resident on the computer, downloaded from the company website. It contains components for LC and a handful of other environments, like C++ and Applescript.
So your turtle has to have that functionality somewhere. USB is only a connectivity (and connector) protocol. It doesn't "do" anything specific.
Does your turtle have that framework inside? Where did those LC-like commands come from?
Craig
Re: Controlling an external device
Posted: Sun Mar 15, 2015 8:57 pm
by richmond62
Two examples are provided below for connection using an active (visual basic) script and programming (C#) language.
The principles should be similar for other programming and active script languages.
2.3.1. Visual Basic
The following line statement should be used :
Set objApp = CreateObject("SilvaElm.R2CommandInterface.R2Command")
2.3.2. C#
The following code may be used to establish connection within the C# programming language:
IR2Command m_r2Command = null;
Type type = Type.GetTypeFromProgID("SilvaElm.R2CommandInterface.R2Command");
m_r2Command = Activator.CreateInstance(type, true) as IR2Command;
IR2Command is the Roamer Command interface:
2.3.2.1. Roamer Command Interface
The Interface (IR2Command) comprises one method and two properties and may be re-implemented in third-party software.
public interface IR2Command
{
string Send(string group, string command, string arguments);
string SendTime { get;}
string ReceiveTime { get;}
}
ReceiveTime and SendTime are for internal programming statistical use only.
Re: Controlling an external device
Posted: Wed Mar 18, 2015 6:25 pm
by richmond62
Here's an odd statement:
"
It is considered that any third-party application will need to invoke the API as an ActiveX object using its ProgId --
bypassing the API by connecting to the USB directly is considered impractical because of the complex programming issues involved."
Now, the people who wrote that want me to try and write a front-end to an external USB thing (a turtle) that works cross-pltform:
obviously they know "dick" to coin a vulgar phrase, about non-Windows.
AND, to have any chance whatsoever the API has to be invoked without reference to ActiveX (a Windows-only thing) or by connecting
directly to the USB connexion.
Re: Controlling an external device
Posted: Wed Mar 18, 2015 6:30 pm
by richmond62
The driver is called "mchpcdc.inf" and I assume (????????) that this is only going to be useful in a Windows environment.
I wonder if there is a way to either:
1. leverage this file on Macintosh and Linux ?????? (sounds unlikely)
2. workout a way to write an "open driver "xxx/xxx/xxx" for binary write" when no driver is present
3. somehow connect to the USB device without a driver (and tease that USB device out from any others that maybe connected to the computer)
??????
Re: Controlling an external device
Posted: Wed Mar 18, 2015 6:45 pm
by richmond62
Craig . . .
according to the Pee-Dee-eff the thing does have "stuff" inside, and I have already referenced the spex on my
DropBox account here:
https://www.dropbox.com/sh/dcmj3jmmubxm ... wD3ma?dl=0
"The API is a COM (Component Object Model) Object that may be used by both third-party software implementors and by active scripting languages such as Visual Basic and Java.
2.1. Installation
The API is installed as part of the RoamerWorld installation available for both Windows 32 and 64 bit operating systems."
and the specifications contain stuff for VB and C++:
"2.3.1. Visual Basic
The following line statement should be used :
Set objApp = CreateObject("SilvaElm.R2CommandInterface.R2Command")
2.3.2. C#
The following code may be used to establish connection within the C# programming language:
IR2Command m_r2Command = null;
Type type = Type.GetTypeFromProgID("SilvaElm.R2CommandInterface.R2Command");
m_r2Command = Activator.CreateInstance(type, true) as IR2Command;"
Which is "all very sexy" as far as it goes. What it does not really do as far as I can see is tell me how to establish a connexion with
LiveCode . . .
After all ONCE ONE HAS ESTABLISHED A CONNEXION everything SHOULD be DEAD EASY:
"Only one method is necessary for sending commands and receiving responses with Roamer. The method definition is:
string Send(string group, string command, string arguments);"
that will be a "walk in the park" . . .
Re: Controlling an external device
Posted: Wed Mar 18, 2015 6:57 pm
by dunbarx
Richmond.
The framework that comes with the B & K gadget is proprietary and simply loads onto your machine. It is automatically recognized the moment a USP cable is plugged into that machine as well as the gadget. Then, in any of the dozen or so languages it supports, a command or interrogation sent to the interface will be executed. I imagine one could switch from one environment to another at will. I do not know what it would take to write an API. I would just buy one of theirs.
Craig
Re: Controlling an external device
Posted: Wed Mar 18, 2015 7:00 pm
by richmond62
Kay C Lan seems to know what s/he's doing:
"open driver tDriverName for text update
write numToChar(1) & cr to driver tDriverName"
and I see NO reason why I shouldn't do that sort of thing myself IFF I know what I have to put into "tDriverName"
http://lists.runrev.com/pipermail/use-l ... 55108.html
what a Big Bu**er!