To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 16598
16597  |  16599
Subject: 
Re: Programming RCX using Delphi
Newsgroups: 
lugnet.robotics
Date: 
Tue, 27 Nov 2001 22:21:15 GMT
Viewed: 
746 times
  
In lugnet.robotics, Stef Mientki writes:
If John Hansen would answer your question, you would even get to know how to
program the USB tower.
(As far as I know all his sources are available, but it's quiet a lot !!)

I wrote what I call a FakeSpirit class in Delphi.  It is what I use in
BricxCC to communicate with the programmable bricks.  The files needed to
use FakeSpirit are in

http://members.aol.com/johnbinder/bricxcc_src.zip

The required files are contained in the "bricktools" sub-directory in this
zip file.  See FakeSpiritTest.dpr for a very simple example of using the
FakeSpirit class.

Here is the current public interface:

TFakeSpirit = class
public
  constructor Create(aType : TRCXType = 0; aPort : TPortNum = 1);
  destructor Destroy; override;

  function  Open : boolean;
  function  Close : boolean;

  // PBrick sound commands
  function PlayTone(aFreq, aTime : integer) : boolean;
  function PlaySystemSound(aSnd : integer) : boolean;

  // PBrick output control commands
  function MotorsOn(aMotorList : Byte) : boolean; // On
  function MotorsOff(aMotorList : Byte) : boolean; // Off
  function MotorsFloat(aMotorList : Byte) : boolean; // Float
  function SetFwd(aMotorList : Byte) : boolean;
  function SetRwd(aMotorList : Byte) : boolean;
  function SwitchDirection(aMotorList : Byte) : boolean; // AlterDir
  function SetMotorPower(aMotorList : Byte; aSrc, aNum : integer) : boolean;
// SetPower

  // PBrick input control commands
  function SetSensorType(aNum, aType : integer) : boolean;
  function SetSensorMode(aNum, aMode, aSlope : integer) : boolean;
  function ClearSensorValue(aNum : integer) : boolean;

  // general
  function TowerExists : boolean; // TowerAlive / TowerAndCableConnected
  function Ping : boolean;
  function PrepareBrick : boolean;
  function UnlockFirmware : boolean;
  function UnlockBrick : string;  // UnlockPBrick
  function DownloadMemoryMap : TStrings; // MemMap
  function PowerDownTime(aTime : integer) : boolean; // PBPowerDownTime
  function BatteryLevel : integer; // PBBattery
  function BrickAlive : boolean; // PBAliveOrNot
  function Shutdown : boolean; // PBTurnOff
  function Sleep(aVal : integer) : boolean;
  function Version(var rom : Cardinal; var ram : Cardinal) : boolean;
  function TransmitPower(aLevel : TTransmitLevel) : boolean; // PBTxPower

  function Poll(aSrc, aNum : integer) : integer;
  function StartTask(aTask : integer) : boolean;
  function StopTask(aTask : integer) : boolean;
  function StopAllTasks : boolean;
  function DeleteTask(aTask : integer) : boolean;
  function DeleteAllTasks : boolean;
  function DeleteSub(aSub : integer) : boolean;
  function DeleteAllSubs : boolean;
  function ClearTimer(aNum : integer) : boolean;
  function ClearMemory : boolean;

  function GetOutputStatus(aOut : integer) : integer;
  function GetVariableValue(aVar: integer): integer;
  function GetInputValue(aIn: integer): integer;
  function GetMessageValue(aNum : integer) : integer;
  function GetTimerValue(aNum : integer) : integer;
  function GetCounterValue(aNum : integer) : integer;

  // PBrick arithmetic/logical commands
  function SetVar(aVar, aSrc, aNum : integer) : boolean;
  function SumVar(aVar, aSrc, aNum : integer) : boolean;
  function SubVar(aVar, aSrc, aNum : integer) : boolean;
  function DivVar(aVar, aSrc, aNum : integer) : boolean;
  function MulVar(aVar, aSrc, aNum : integer) : boolean;
  function SgnVar(aVar, aSrc, aNum : integer) : boolean;
  function AbsVar(aVar, aSrc, aNum : integer) : boolean;
  function AndVar(aVar, aSrc, aNum : integer) : boolean;
  function OrVar(aVar, aSrc, aNum : integer) : boolean;

  // communication to brick
  function SendRawCommand(aCmd : string; bRetry : boolean) : string;
  function SendRemote(aEvent : string; aRepeat : integer = 1) : boolean;
overload;
  function SendRemote(aEvent : Word; aRepeat : integer = 1) : boolean; overload;
  function SendMessage(aMsg : integer) : boolean;

  // RCX only
  function SelectProgram(aProg : integer) : boolean; // SelectPrgm
  function SelectDisplay(aSrc, aNumber : integer) : boolean;
  function SetWatch(aHrs, aMins : integer) : boolean; overload;
  function SetWatch(aTime : string) : boolean; overload;
  function DownloadFirmware(aFile : string; bFast : boolean) : boolean;
  function SetDatalog(aSize : integer) : boolean;
  function DatalogNext(aSrc, aNum : integer) : boolean;
  function UploadDatalog(aFrom, aSize : integer) : TStrings; overload;
  function UploadDatalog(bVerbose : boolean) : TStrings; overload;

  // CM only methods
  function Drive(aLeft, aRight : integer) : boolean;
  function ClearTachoCounter(aMotorList : Byte) : boolean;
  function OnWait(aMotorList : Byte; aNum : integer; aTime : Byte) : boolean;
  function OnWaitDifferent(aMotorList : Byte;
    aNum0, aNum1, aNum2 : integer; aTime : Byte) : boolean;

  // Scout only methods
  function Scout(aVal : integer) : boolean; overload;
  function Scout(bPower : boolean = true) : boolean; overload;
  function CalibrateLightSensor : boolean;
  function SendVLL(aSrc, aNum : integer) : boolean;
  function SetFeedback(src, val : integer) : boolean;
  function SetLightSensorUpperThreshold(src : TLSSource; val :
TThresholdValue) : boolean;
  function SetLightSensorLowerThreshold(src : TLSSource; val :
TThresholdValue) : boolean;
  function SetLightSensorHysteresis(src : TLSSource; val : TThresholdValue)
: boolean;
  function SetLightSensorBlinkTime(src : TLSSource; val : TBlinkTimeValue) :
boolean;
  function SetTimerLimit(num : TTimerNumber; src : TTCSource; val : integer)
: boolean;
  function SetCounterLimit(num : TCounterNumber; src : TTCSource; val :
integer) : boolean;
  function ScoutLight(bOn : boolean) : boolean;
  function ScoutRules(motion : TScoutMotion; touch : TScoutTouch;
    light : TScoutLight; time : TScoutScale; fx : TScoutEffects) : boolean;
  function ScoutSound(bSoundEnable : boolean; bSoundOff : boolean; aNum :
TSoundSetNumber) : boolean;

  // RCX2 & Scout methods
  function PollMemory(address, size : integer) : TStrings;
  function SetGlobalOutput(motors : TMotorsNum; action : TGlobalOutAction) :
boolean;
  function SetGlobalDirection(motors : TMotorsNum; action :
TGlobalDirAction) : boolean;
  function SetMaxPower(motors : TMotorsNum; src, num : integer) : boolean;
  function IncCounter(num : TCounterNumber) : boolean;
  function DecCounter(num : TCounterNumber) : boolean;
  function ClearCounter(num : TCounterNumber) : boolean;

  // RCX2 only methods
  function ClearSound : boolean;
  function MuteSound : boolean;
  function UnmuteSound : boolean;
  function SendUARTData(start, size : integer) : boolean;
  function SetEvent(enum, snum, etype : integer) : boolean;
  function CalibrateEvent(enum, upper, lower, hysteresis : integer) : boolean;
  function ClearAllEvents : boolean;
  function ViewSourceValue(prec, src, value : integer) : boolean;

  // properties
  property  FastMode : boolean read fFastMode write SetFastMode;
  property  RCXType : TRCXType read FRCXType write SetRCXType;
  property  PortNum : TPortNum read FPortNum write SetPortNum;
  property  PortName : string read GetPortName;
  property  NicePortName : string read GetNicePortName;
  property  RxTimeout : Word read fRxTimeout write fRxTimeout;
  property  VerboseMode : boolean read fVerbose write SetVerbose;
  property  AutoClose : boolean read fAutoClose write fAutoClose;
  property  DataLog : TStrings read fDataLog;
  property  MemoryMap : TStrings read fMemMap;
  property  OnDownloadStart : TNotifyEvent read fOnDownloadStart write
fOnDownloadStart;
  property  OnDownloadDone : TNotifyEvent read fOnDownloadDone write
fOnDownloadDone;
  property  OnDownloadStatus : TDownloadStatusEvent read FOnDownloadStatus
write FOnDownloadStatus;
end;



Message is in Reply To:
  Re: Programming RCX using Delphi
 
hi Robert, Besides using spirit.ocx (I threw it away because of it's limitations and strange behaviour), you can also send/receive commands through a normal RS232 driver. I've done this in Delphi-5 (only RS232), you can download my sources here: (...) (23 years ago, 26-Nov-01, to lugnet.robotics)

6 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR