Re: [BLACKBOX] PC Ports

From: [at]} <Rex>
Date: Tue, 28 Aug 2012 16:07:47 -0500

----boundary-LibPST-iamunique-1874846520_-_-
Content-type: text/plain

At 03:03 PM 8/28/2012, Robert wrote:
>This is more of a Windows question rather than BlackBox, I think,
>but does anyone know how to write a simple (ASCII) string to the RS232
>port and to the Bluetooth port?

        I don't know about Bluetooth, but BB has a nice RS232 implementation using CommV24. At a minimum you need to use Open, SetBuffers, SendBytes, and Close. Here's a sample program.

(* DevLinker.LinkExe
CrashEcho.exe := Kernel+ CommV24 Fonts Ports Files Dialog Math Strings Stores Log Services Sequencers Models Meta Converters Views Controllers Properties HostFiles HostRegistry HostFonts HostPorts Printers Dates Printing Mechanisms Containers Documents Windows OleData HostMechanisms HostWindows XYplane TextModels TextMappers TextRulers TextSetters TextViews HostPrinters StdDialog StdApi StdCmds StdCFrames HostCFrames HostDialog TextControllers StdLog Out Echo ~ *)

MODULE Echo;
(* Echos serial communications *) (* Crashes as stand-alone app. Possilyb ReadKey problem? BB trap #100 Dialog.Call *)

IMPORT CommV24, XYplane, Out;

CONST
        baud = 2400;

VAR
        c: CommV24.Connection;
        inVar, outVar: ARRAY 256 OF BYTE;
        nReady: INTEGER;

PROCEDURE Init;
BEGIN
        CommV24.Open( 'COM1:', baud, {}, c);
        CommV24.SetBuffers( c, 1024, 1024);
END Init;

PROCEDURE Done;
BEGIN
        CommV24.Close( c);
END Done;

PROCEDURE Do*;
BEGIN
        Init;
        Out.String( 'Press a key to terminate'); Out.Ln;
        REPEAT
                nReady:= CommV24.Available( c);
                IF (nReady > 0) THEN
                        CommV24.ReceiveBytes( c, inVar, 0, nReady); (* But will buffers always be ready? *)
                        CommV24.SendBytes( c, inVar, 0, nReady);
                        END
        UNTIL (XYplane.ReadKey() # 0X);
        Done;
END Do;



Rex Couture


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1874846520_-_-
Content-type: application/rtf
Content-transf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hcg0KLS0tLVxw
YXINClRvIHVuc3Vic2NyaWJlLCBzZW5kIGEgbWVzc2FnZSB3aXRoIGJvZHkgIlNJR05PRkYgQkxB
Q0tCT1giIHRvIExJU1RTRVJWQExJU1RTLk9CRVJPTi5DSH19AEJUPTE=
----boundary-LibPST-iamunique-1874846520_-_---
Received on Tue Aug 28 2012 - 23:07:47 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:29:58 UTC