Belgium
Asked — Edited

Help With Syntax To Call Ez_B.Dll Functions (Python)

Hi,

I've tried all sensible combinations I can think of to call EZ_B.dll functions in Python. I know if I can get the syntax right for one, the rest will follow.

Any suggestion appreciated.

David.


from ctypes import *

> libEZB = CDLL("C:\Documents and Settings\David\My Documents\EZ-SDK\DLL\EZ_B.dll")

> libEZB Out[9]: <CDLL 'C:\Documents and Settings\David\My Documents\EZ-SDK\DLL\EZ_B.dll', handle 4470000 at 28e4710>

> libEZB.ObjectLocation.TrackingType

AttributeError: function 'ObjectLocation' not found

> libEZB.EZ_B.ObjectLocation.TrackingType

AttributeError: function 'ObjectLocation' not found


ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

Belgium
#1  

Progress:

I downloaded IronPython, as suggested by DJ.

>>> import clr >>> import sys >>> >>> sys.path.Add(r"C:\Documents and Settings\David\My Documents\EZ-SDK\DLL") 5 >>> clr.AddReference ("EZ_B.dll") >>> import EZ_B >>> EZ_B <module 'EZ_B' (CLS module from EZ_B, Version=2013.1.29.0, Culture=neutral, Publ icKeyToken=c3a3457c97d352d9)> >>> EZ_B.RoboSapien <type 'RoboSapien'> >>> EZ_B.EZB_Connect.Connect() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Connect() takes exactly 2 arguments (0 given)

PRO
Synthiam
#2  

I've never used either. Nor have I ever used python:) I'm not sure what the log files are from. Do you have all of the DLL files included in the SDK ZIP package in your EZ_SDK folder?

Keep in mind that any Python modules you use are open source, and therefore no quality assurance. You won't be able to determine if you're doing something incorrectly, or the python software has bugs. That's always a battle with opensource, sadly... I don't want to pawn you off somewhere else, but it might be beneficial to find an experienced python forum for assistance.

I'd love to see your progress though:)

Belgium
#3  

DJ Sures said: "I'm not sure what the log files are from."

Inputs and outputs from the IronPython command console.

Progress:

> ezb = EZ_B.EZB() > ezb

<EZ_B.EZB object at 0x0000000000000031 [EZ_B.EZB]>

> ezb.Connect('com6')

at this point the red bluetooth light stops flashing, happy, happy

> ezb.RoboSapien.SendCommand(EZ_B.RoboSapien.RoboSapienCmdEnum.Fart)

Nada

So I'm still missing something. The difficult thing at this point is working out how to translate the C# syntax (commands, parameters, options) into the Python syntax. Is there a more compete listing than found here: https://synthiam.com/SDK/ ? Opening up the .dll in Visual Studio does not give me the parameters that are passed to the functions/methods, as far I as can find.

PRO
Synthiam
#4  

I don't think there is anyway to provide you a more complete listing. To obtain the values of that robosapien enumeration, you'd have to query the object. That's normally done in the IDE. It might be good to copy syntax from the SDK example projects?

Also, if you don't have visual studio, you can download a full trial or the Express version. Express i think works great - although i have never used it.

When you send the robosapien command "fart", do you receive an error? or just nothing happens?

The EZ-B will auto disconnect if there is more than 2 seconds between receiving commands. The best way to ensure there is a connection is to send a 0x55 (capital letter U) to the EZB every 2 seconds.

Belgium
#5  

Good tips ... I'll try them tomorrow. The blue light does flicker every few seconds, and the red light stays on. Does this mean it's still connected, or can't you tell from the lights? If 'no', then I'll whack in a loop that sends 0x55 as you suggest. What is the c# syntax for sending this?

I was just doing some reading on querying known objects using the ctypes module in Python, but haven't tried it yet. Hopefully, once I get the querying working, it's just a matter of trial and error to guess the right Python syntax for arbitrary commands in the EZ_B.dll.

Is the raw c code, from which the EZ_B.dll was compiled, posted somewhere? This at least would have all the definitions I require, even if it's a bit opaque.

I downloaded trial version of Visual Studio, and made some progress by looking inside the .dll.

Progess:

> import clr > import sys > sys.path.Add(r"C:\Documents and Settings\David\My Documents\EZ-SDK\DLL") > clr.AddReference ("EZ_B.dll") > import EZ_B

> my_ezb = EZ_B.EZB() > my_ezb.Connect('com6')

red light on

> f = my_ezb.RoboSapien.RoboSapienCmdEnum.WakeUp

> f EZ_B.RoboSapien+RoboSapienCmdEnum.WakeUp

> my_ezb.RoboSapien.SendCommand(f)

no errors, but no response

Belgium
#7  

Hi DJ,

Yes, I was controlling the Robosapien with the wiimote in ARC from the 2nd day.

Progress:

>>> import clr >>> import sys >>> from time import * >>> sys.path.Add(r"C:\Documents and Settings\David\My Documents\EZ-SDK\DLL") 5 >>> clr.AddReference ("EZ_B.dll") >>> import EZ_B >>> >>> my_ezb = EZ_B.EZB() >>> my_ezb.Connect('com6') >>> #my_ezb.Name = "my_ezb" >>> >>> while True: ... print my_ezb.IsConnected ... sleep(1.0) ... command = my_ezb.RoboSapien.RoboSapienCmdEnum.Fart ... print command ... my_ezb.RoboSapien.SendCommand(command) ... sleep(1.0) ... command = my_ezb.RoboSapien.RoboSapienCmdEnum.Burp ... print command ... my_ezb.RoboSapien.SendCommand(command) ... True Fart Burp True Fart Burp

Robosapien farts and burps

So it seems the missing magic ingredient was, as you suggested, something to stop the auto disconnect.

In a week or so I'll post a bunch of Python examples for others to follow.

David.

PRO
Synthiam
#8  

I'm looking forward to that! I like that you're adventerous in taking the python challenge!

Belgium
#9  

one last question for now ...

how do I do this in c#:

"send a 0x55 (capital letter U) to the EZB every 2 seconds"

PRO
Synthiam
#10  

Just use Ping() command is enough