Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

B4PPC & Mindsqualls DLL

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-01-2009, 03:47 PM
Newbie
 
Join Date: Feb 2009
Posts: 3
Default B4PPC & Mindsqualls DLL

Hello,

I am considering to buy B4PPC.
The main purpose of B4PPC is to connect to my Brick of the Lego Mindstorn (NXT).
I found at mindsqualls.net a NET DLL which I could install in B4PPC.
My questions:
In Vb.NET there are the possibility to import the DLL Thru "Imports".
In B4PPC this will be done thru "Components" which I did.
After creating a new Object there were several properties missing which normally found in VB.Net.
Could somebody give me an advise how to get the whole properties.
I can connect to the NXT and use some of the properties ie. "Brick.Name" & "Brick.GetBatteryLevel" but some are missing.
In addition to that in VB.Net if I used brick.Commlink. .... there are another
properties behind which I can't use in B4PPC.
(Pfffff. yery tough to explain)
Is there any way to create below's code in B4PPC:

Code:
i.e.: Dim brick as New NxtBrick 
       brick = New NxtBrick(COMPortName)
It would be highly appreciated if somebody can help me to get this DLL working.

Thanks in advance
Thomas
Reply With Quote
  #2 (permalink)  
Old 04-01-2009, 05:34 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Constructors are converted into Object.New1, Object.New2...
Can you provide some details about the API of this library?
You will most probably need some (simple) wrapper library in order to work with this library.
Reply With Quote
  #3 (permalink)  
Old 04-01-2009, 05:48 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

You seem to be familiar with VB.NET. Is there a reason not to use VB.NET for your application - like maybe it won't compile for the device?

The reason you can't use some of the properties are that they return types of objects that Basic4ppc can't understand. It really only understands the primitive types and Color as library parameter and return types. As the source of the library is available (I've downloaded and compiled it OK) you could modify it to suit your needs, but maybe you aren't happy with C#.

You can make a brick by adding an object named "Brick " as a NxtBrick, Tools->AddObject, and instantiate it with

Brick.New2(COMPortName)

You could also add it at runtime but you lose the automatic listing of properties and methods at design time.

AddObject("Brick", "NxtBrick")
Brick.New2(COMPortName)

EDIT:- The properties you can't see in Basic4ppc can probably be manipulated with the Door library, obj1 is a Door library Object.

obj1.New1(False)
obj1.Value = Brick.CommLink
obj1.RunMethod("Connect")

but maybe this is getting a bit arcane

Last edited by agraham : 04-01-2009 at 05:56 PM.
Reply With Quote
  #4 (permalink)  
Old 04-01-2009, 08:04 PM
Newbie
 
Join Date: Feb 2009
Posts: 3
Default

Dear Erel,
dear agraham,

thanks a lot for the fast reply.
I am not so familar with VB.Net. I could compile my programm to the Emulator as well as to the Device. The problem was only that I could'nt established the BT Connection by starting my program. I got always a system exception. Only if I create the BT connection before I start my program I was able to connect the NXT.
I also compiled the Mindsqaulls with C# and the DLL works and you are right
I don't like C# because for me it's totally confusing and for sure I'm not able to modified the code. Delphi
If I embedded the DLL in B4PPC there are several Objects are available.
I.e.: NXTBrick, NXTBluetooth

Please see hereafter:

Code:
Variable "port" is in Sub GLOBAL

Sub App_Start
nxtbrick.New1(port)   
'Create New1 with COM5
End Sub
Sub mnuConnect_Click
    ErrorLabel(btnConnectErr)
        nxtbrick.Connect
        
If nxtbrick.IsConnected Then
        ModGeneral.Connected
        
End If
    
Return
       btnConnectErr:
       
Msgbox("Kann Anschlu� " & port & " nicht �ffnen""Fehler")
       
If nxtbrick.IsConnected Then 'close port
       nxtbrick.Disconnect
       ModGeneral.NotConnected 
       
Else
       nxtbrick.IsConnected
       ModGeneral.Connected
       
Sender.LabConnect.Color = 255,0,0 
       
End If
End Sub
The above code works well with the Mindsquall DLL but only for the object
"NXTBrick".
If I try now to get information from the object "NXTBluetooth" like
"NXTBluetooth.GetFirmwareVersion" I create an Error because
NXTBluetooth.New1(port) is not open. But I can't open due to
the open NXTBrick.New1.

Is there any possibility to bypass the NXTBluetooth.New with any command in B4PPC and get the information thru NXTBrick's open port?

I hope you could understand what my problem are.
Thanks for your Feedback

Thomas

Last edited by ToGi : 04-01-2009 at 09:39 PM.
Reply With Quote
  #5 (permalink)  
Old 04-02-2009, 09:16 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by ToGi View Post
I create an Error because
NXTBluetooth.New1(port) is not open.
It's really a bit too complicated to explain here but NextBrick.New1 followed by NextBrick.Connect creates a NxtBluetoothConnection object and stores it in its CommLink property. You would need to use this CommLink object, not the one you created, to communicate.

This is a very low-level library with no explanatory documentation. The documentation is just a bald list of classes with their methods and properties. To use this library you would need to know about how .NET classes and objects work and to understand what it can do you need to know about the BDK which the documentation references - I assume this is is the Lego Brick Development Kit. You seem to have access to Visual Studio so if you don't already understand VB.NET then I am afraid that you might have a long learning curve ahead of you!
Reply With Quote
  #6 (permalink)  
Old 04-02-2009, 09:52 PM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

@ToGi
I am afraid that I'm not able to answer your question and instead want to ask a question of my own...

I have been considering buying a LEGO Mindstorm kit for my son as a means of introducing him to programming. I believe that it is loosely based on the National Instruments programming platform (I've previous experience using NI to control vision inspection systems).
Do you feel that this would be a good start for my son, who is 10 next month, to get involved in programming and mechatronics?

Regards,
RandomCoder
PS Sorry for taking this thread
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #7 (permalink)  
Old 04-03-2009, 11:14 AM
Newbie
 
Join Date: Feb 2009
Posts: 3
Default

@ agraham
I understood the explanation from you regarding open port.
I have Microsofts Visual Studio 2008 and I create the same code for VB.Net
which I created for B4PPC. But also this creates other problems which former
worked quite well in B4PPC. (I like this Smiley).
In B4PPC directly after initialisation and opening port I got the BT connection.
But Now with VB.Net it's much more complicated and I got another error which I could'nt understand.
Anyway, this is a B4PPC based Website and I think that B4PPC have a lot of advantages which are better than VB.Net (one of them is that VB.Net is much more complicated).

I have to find a way to communicate which the PPC & LegoBrick in whatever way. Maybe next version of B4PPC

Anyway, thanks a lot to agrahm and erel to taking care my questions.

@ RandomCoder

My son is 10 years old and my intention was and is to guide him in a kittenish way to mechatronics and programming.

I am involved in John Hansen's BricxCC for Legos bricks as a beta tester and I translated the above mentioned program in my native german language and changed something in the code to make it easy for my son to program the Lego Mindstorm Brick in bloody similar C programming language named NXC, but by today it's a little bit hard for my son to understand text based programming language.

Of course, the software of Mindstorm is based upon NI's Labview with some limitations where my son is now programming with.
If you are familar with NI's Labview you can also download an SDK for Mindstorm on NI website with much more complex possibilities than the normal Lego software, but it's very tough I guess.

From my point of you, I think this is one of the best opportunities to start programming for kids in a very easy and funny way, because if your son
is using the orignal software of Lego Mindstorm he will have an WYSIWYG
like effect.
Reply With Quote
  #8 (permalink)  
Old 04-03-2009, 01:25 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by ToGi View Post
I have to find a way to communicate which the PPC & LegoBrick in whatever way. Maybe next version of B4PPC
I don't think that the next version of Basic4ppc will have anything in it that will help. Basic4ppc cannot handle non-primitive parameters and return values of external libraries.

If you want to stay with Basic4ppc then the Door library used with my DoorEx library (you have to buy Basic4ppc to be able to access the additional libraries) should let you manipulate the things that Basic4ppc itself can't handle. But doing it this way would be clumsy and need almost as much knowledge of .NET as needed to rewrite the library in the first place.

This is a flavour of what would be needed, obviously I haven't tried this to see if it works. Brick is a NxtBrick object, MotorA is a NxtMotor object, obj1 is a Door library Object object, objex1 is a DoorEx library ObjectEx object.
Code:
Brick.New1(COMPort)
MotorA.New1
obj1.New1(
False)
objex1.New1(B4PObject(
2))
  ...
Brick.Connect
bl = Brick.BatteryLevel 
' this should work as it returns a UInt which B4P understands
  ...
' the following does "Brick.MotorA = new NxtMotor();"
objex1.FromString("MotorA"' get a reference to MotorA which we created earlier
Brick.SetProperty2("MotorA", objex1.Value)
' and then run at 75% power of 10 turns "Brick.MotorA.Run(75, 3600);"
MotorA.RunMethod3("Run"75"System.Int32"3600"System.Int32")
Reply With Quote
  #9 (permalink)  
Old 04-05-2009, 11:59 AM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by ToGi View Post
From my point of you, I think this is one of the best opportunities to start programming for kids in a very easy and funny way, because if your son
is using the orignal software of Lego Mindstorm he will have an WYSIWYG
like effect.
Thank you for your reply ToGi, my mind was pretty much set on the idea of getting my lad the Mindstorm kit and you have helped to confirm that this is a worthwhile investment.

Regards,
RandomCoder
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
NSBasic To B4PPC ceaser Questions (Windows Mobile) 7 06-02-2008 10:21 PM
B4PPC on USB stick Put Claude Questions (Windows Mobile) 1 01-04-2008 01:33 PM
must B4PPC be installed on C:\ Put Claude Questions (Windows Mobile) 4 01-02-2008 12:05 PM
SQLite 3 and b4ppc magi6162 Questions (Windows Mobile) 1 08-23-2007 01:36 PM
not b4ppc but the forum Cableguy Forum Discussion 1 04-29-2007 06:10 AM


All times are GMT. The time now is 04:10 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0