----boundary-LibPST-iamunique-747030705_-_-
Content-type: text/plain
Hi
In Blackbox the RS232 is called V24 and implemented and doesn't require a
dll. Search help for V24.
This program will blink a led in 1 sec interval.
------------------------------------------
MODULE ExampleV24Toggle;
IMPORT Services, Print := StdLog, V24 := CommV24;
TYPE
Action = POINTER TO RECORD (Services.Action) END;
VAR
a: Action; (* Action (Task) variable *)
conn: V24.Connection; (* Connection variable *)
toggle: BOOLEAN;
(* Receive *)
PROCEDURE (a: Action) Do;
BEGIN
V24.SetDTR(conn, toggle);
V24.SetRTS(conn, toggle);
toggle := ~toggle;
Services.DoLater(a, Services.Ticks() + 1000) (* Run DO task
in 1000ms again *)
END Do;
PROCEDURE Start*;
BEGIN
(* empty procedure to load module *)
END Start;
BEGIN
V24.Open("COM1:", 19200, {}, conn);
Print.Clear(); Print.Open();
IF conn # NIL THEN
Print.String("Port opened!"); Print.Ln();
IF a = NIL THEN
NEW(a);
Services.DoLater(a, Services.now); (* Callback task
to the DO action *)
Print.String("Do (toggle) task activated!");
END;
ELSE
Print.String("Could not open port!");
END;
Print.Ln()
CLOSE
(* CLOSE runs when the module gets unloaded *)
(* via Dev -> Compile and Unload or by closing the app *)
IF conn # NIL THEN V24.Close(conn) END;
Print.Open(); Print.String("COM1 closed"); Print.Ln();
Services.RemoveAction(a);
END ExampleV24Toggle.
ExampleV24Toggle.Start
---------------------------------------------------
Using the parallel port is described here:
http://www.elec.canterbury.ac.nz/PublicArea/Staff/hof/p50-win/p10-parport/
Philipp
-----Original Message-----
From: frans-pietervonck{([at]})nowhere.xy
Sent: Saturday, 27 May 2006 10:21 a.m.
To: blackbox{([at]})nowhere.xy
Subject: [BlackBox] - blinking a led: Delphi PCHAR->CP array?
Hello Blackboxers,
I want to blink a led using using Kainka's "PC Interfaces under Windows".
The book comes with a dll - PORT.DLL - which enables communication with
the serial ports under XP.
With Delphi the led blinks. In BlackBox, I can't get it light. I suspect
that my way of translating the delphi PCHAR-type
into an array is not correct. Can I use an array as an null terminated
string? Anyone some advice?
In delphi, opening the com-port is done as follows.
Function OPENCOM(S:PCHAR):Integer;stdcall; external PORT.DLL;
for example: OpenCom (Pchar('COM1:9600,N,8,1'));
OpemCom returns a 1 when connected, 0 when failed.
Following my the translation of the function to component pascal
INTERFACE:
constr* = ARRAY 18 OF CHAR;
PROCEDURE opencom* ["OPENCOM"]
(Constr:constr) : INTEGER;
TESTFUNCTION:
open := PortDLL.opencom("COM1:9600,N,8,1");
The two modules I've used.
-----------------------
INTERFACE
----------------------
MODULE PortDLL ["PORT.DLL"];
IMPORT SYSTEM;
TYPE
constr* = ARRAY 18 OF CHAR;
PROCEDURE opencom* ["OPENCOM"]
(Constr:constr) : INTEGER;
END PortDLL.
----------------------------------
TESTMODULE
----------------------------------
MODULE TestPort;
IMPORT PortDLL, StdLog;
VAR open: INTEGER;
PROCEDURE Do*;
BEGIN
open := 3;
open := PortDLL.opencom("COM1:9600,N,8,1");
IF open = 1 THEN
StdLog.String("Opening COM1 successful. "); StdLog.Ln
END;
IF open = 0 THEN
StdLog.String("Opening COM1 failed."); StdLog.Ln
END;
END Do;
END TestPort.
-----------------------------------
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
----boundary-LibPST-iamunique-747030705_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcY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lOXHBhcg0KICAg
ICAgICBvcGVuIDo9IDM7XHBhcg0KICAgICAgICBvcGVuIDo9IFBvcnRETEwub3BlbmNvbSgiQ09N
MTo5NjAwLE4sOCwxIik7XHBhcg0KICAgICAgICBJRiBvcGVuID0gMSBUSEVOXHBhcg0KICAgICAg
ICAgICAgU3RkTG9nLlN0cmluZygiT3BlbmluZyBDT00xIHN1Y2Nlc3NmdWwuICIpOyBTdGRMb2cu
TG5ccGFyDQogICAgICAgIEVORDtccGFyDQogICAgICAgIElGIG9wZW4gPSAwIFRIRU5ccGFyDQog
ICAgICAgICAgICBTdGRMb2cuU3RyaW5nKCJPcGVuaW5nIENPTTEgZmFpbGVkLiIpOyBTdGRMb2cu
TG5ccGFyDQogICAgICAgIEVORDtccGFyDQogICAgRU5EIERvO1xwYXINClxwYXINCkVORCBUZXN0
UG9ydC5ccGFyDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLVxwYXINClxwYXIN
Ci0tLSBCbGFja0JveFxwYXINCi0tLSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlNDUklCRSB0
byBibGFja2JveEBvYmVyb24uY2hccGFyDQpccGFyDQotLS0gQmxhY2tCb3hccGFyDQotLS0gc2Vu
ZCBzdWJqZWN0IEhFTFAgb3IgVU5TVUJTQ1JJQkUgdG8gYmxhY2tib3hAb2Jlcm9uLn19AGwgYmxp
bmsgYSBsZQ==
----boundary-LibPST-iamunique-747030705_-_---
Received on Mon May 29 2006 - 22:22:58 UTC