DECUServe VMS Conference 3064.8

     
Next-Reply Prev-Reply    Next-Topic Prev-Topic    ConfDir-Paged-New>Old ConfDir-Paged-Old>New   ConfDir-All-New>Old ConfDir-All-Old>New
       
Directory of conferences This topic directory


Note 3064.8            X10 / X-10 / BSR / Home Automation                8 of 15

EISNER::COVERT "John.Covert@Compaq.com"             138 lines  10-JAN-2000 09:51

                                 -< CM11.BLI >-

--------------------------------------------------------------------------------

module cm11 (main = start, addressing_mode(external=general))=

begin



require 'sys$library:starlet';



macro 

    dsc_0 (buffer) = $BBLOCK[8] INITIAL (LONG(128), LONG(BUFFER)) %;



external routine

	lib$put_output;



routine start =

begin



LOCAL

    status,

    chan: initial(0),

    iosb:    VECTOR[4,word],

    buffer:  VECTOR[128,byte],

    bufdesc:  dsc_0(buffer),

    ch: byte,

    noterms: quad initial(0);



    status = $assign(devnam=%ascid'TERM_DEV',chan=chan);

    if not .status then SIGNAL_STOP(.status);



!

! Read forever

!

    while 1 do

	begin

	status = $qiow (

			chan   = .chan,

			func   = io$_readvblk,

			iosb   = iosb,

			p1     = buffer,

			p2     = 1);

	if not .status then SIGNAL_STOP(.status);

	if not .iosb[0] then signal_stop (.iosb[0]);

	ch = .buffer[0];

	bufdesc[dsc$w_length]=128;

	status = $fao (

			%ascid'!%D !XB',

			bufdesc[dsc$w_length],

			bufdesc,

			0,.ch);

	if not .status then SIGNAL_STOP(.status);

	if not .iosb[0] then signal_stop (.iosb[0]);

	status = lib$put_output(bufdesc);

	if not .status then SIGNAL_STOP(.status);

	if not .iosb[0] then signal_stop (.iosb[0]);

!

! If the character indicates we have X10 data, go get it

!

	if .ch eqlu %x'5A'

	then

	    begin

	    buffer[0] = %x'C3';		! This command to the CM11 gets the data

	    status = $qiow (

			chan   = .chan,

			func   = io$_writevblk,

			iosb   = iosb,

			p1     = buffer,

			p2     = 1);

	    if not .status then SIGNAL_STOP(.status);

	    if not .iosb[0] then signal_stop (.iosb[0]);

	    end;

!

! Continue with main loop waiting for response

!

	if .ch lequ 10 and ch nequ 0		! Expected response: count

	then

	    begin

	    !

	    ! Read the number of characters we were told to get

	    !

	    status = $qiow (

			chan   = .chan,

			func   = io$_readvblk,

			iosb   = iosb,

			p1     = buffer[1],

			p2     = .ch,

			p4     = noterms);

	    if not .status then SIGNAL_STOP(.status);

	    if not .iosb[0] then signal_stop (.iosb[0]);

	    bufdesc[dsc$w_length]=128;

	    status = $fao (

			%ascid'!%D !#(XB)',

			bufdesc[dsc$w_length],

			bufdesc,0,

			.ch+1,

			.ch,

			.buffer[1],

			.buffer[2],

			.buffer[3],

			.buffer[4],

			.buffer[5],

			.buffer[6],

			.buffer[7],

			.buffer[8],

			.buffer[9],

			);

	    if not .status then SIGNAL_STOP(.status);

	    if not .iosb[0] then signal_stop (.iosb[0]);

	    status = lib$put_output(bufdesc);

	    if not .status then SIGNAL_STOP(.status);

	    if not .iosb[0] then signal_stop (.iosb[0]);

	    end;

!

! If the character indicates a powerfailure, reset the CM11 controller

!

	if .ch eqlu %x'A5'

	then

	    begin

	    buffer[0] = %x'9B';		! This tells the CM11 to shut up

	    buffer[1] = 0;

	    buffer[2] = 0;

	    buffer[3] = 0;

	    buffer[4] = 0;

	    buffer[5] = 0;

	    buffer[6] = 0;

	    status = $qiow (

			chan   = .chan,

			func   = io$_writevblk,

			iosb   = iosb,

			p1     = buffer,

			p2     = 7);

	    if not .status then SIGNAL_STOP(.status);

	    if not .iosb[0] then signal_stop (.iosb[0]);

	    end;



	end;	! of while 1 do loop



ss$_normal

end;



end

eludom


     
Next-Reply Prev-Reply    Next-Topic Prev-Topic    ConfDir-Paged-New>Old ConfDir-Paged-Old>New   ConfDir-All-New>Old ConfDir-All-Old>New
       
Directory of conferences This topic directory

DECUServe on-line conferencing system - consulting for peanuts

DECnotes Script provided by Roland Kessi, 21 February 1996