english
version "1.0"
identify ""
# Copyright (c) 2000-2001 by Wayne C. Gramlich.
# All rights reserved.
#
# Permission to use, copy, modify, distribute, and sell this software
# for any purpose is hereby granted without fee provided that the above
# copyright notice and this permission are retained. The author makes
# no representations about the suitability of this software for any purpose.
# It is provided "as is" without express or implied warranty.
module parallel_server
#: This module monitors the traffic between a client and a server
#, communicating via a TCP stream.
define options
record
debug logical #: {true
}=>debug mode on
parallel_port_base string #: Parallel port base
generate allocate, erase, print
define parallel #: Parallel port object
record
c unsigned #: Current C register value
c_default unsigned #: Default C register value
d unsigned #: Current D register value
d_default unsigned #: Default D register value
mask unsigned #: Mask register
memory memory #: Temporary {memory
} object
port_base unsigned #: Port base
port_descriptor unsigned #: Port descriptor
unix_system unix_system #: The {unix_system
} object
generate allocate, erase, print
define pic #: PIC configuration
record
clock unsigned #: Clock configuration
clock_input unsigned #: Pattern for clocked input bit
clock_one unsigned #: Pattern for clocked 1 bit
clock_zero unsigned #: Pattern for clocked 0 bit
command_pause unsigned #: Number of milliseconds after command
data_input unsigned #: Pattern for unclocked input bit
data_mask unsigned #: Data mask
data_one unsigned #: Pattern for unclocked 1 bit
data_out unsigned #: Data_out configuration
data_zero unsigned #: Pattern for unclocked 0 bit
enable unsigned #: Enable configuration
increment_command unsigned #: Increment command
input unsigned #: Input configuration
input_invert logical #: Input inversion
input_mask unsigned #: Input mask
load_command unsigned #: Load command
over_programs unsigned #: Over program count
parallel parallel #: Parallel object to use
power unsigned #: Power configuration
program unsigned #: Program configuration
program_command unsigned #: Program command
program_attempts unsigned #: Max. number of attempts to program
read_command unsigned #: Read command
sleep unsigned #: Sleep to program
stop_command unsigned #: Stop command
word_width unsigned #: Word width
generate allocate, erase, print
procedure main
takes
system system
returns unsigned
#: This procedure will monitor some TCP connections between multiple
#, clients of one server.
#: {parallel
} routines:
procedure create@parallel
takes
port_base unsigned
returns parallel
#: This procedure will create and return a new {parallel
} object.
procedure c_write@parallel
takes
parallel parallel
c unsigned
returns_nothing
#: This procedure will write {c
} to {parallel
}.
procedure cd_write@parallel
takes
parallel parallel
cd unsigned
returns_nothing
#: This procedure writes {cd
} to {parallel
}.
procedure d_read@parallel
takes
parallel parallel
returns unsigned
#: This procedure will read and return the D register for {parallel
}.
procedure d_write@parallel
takes
parallel parallel
d unsigned
returns_nothing
#: This procedure will write {d
} to {parallel
}.
procedure defaults_restore@parallel
takes
parallel parallel
returns_nothing
#: This procedure will restore the defaults for {parallel
}.
procedure defaults_save@parallel
takes
parallel parallel
returns_nothing
#: This procedure will set the C and D register defaults.
procedure s_read@parallel
takes
parallel parallel
returns unsigned
#: This procedure will read the S register from {parallel
}.
procedure sleep@parallel
takes
parallel parallel
milliseconds unsigned
returns_nothing
#: This procedure will sleep for {millisconds
} milliseconds.
#: {pic
} commands:
procedure bit_get@pic
takes
pic pic
returns unsigned
#: This procedure will return one bit from {pic
}.
procedure bit_put@pic
takes
pic pic
bit unsigned
returns_nothing
#: This procedure will send {bit
} to {pic
}.
procedure create@pic
takes
parallel parallel
returns pic
#: This procedure will create and return a {pic
} object that uses
#, {parallel
}.
procedure command_put@pic
takes
pic pic
command unsigned
returns_nothing
#: This procedure will send {command
} to {pic
}.
#put@("\n\", debug_stream)
procedure data_get@pic
takes
pic pic
returns unsigned
#: This procedure will get one word of data from {pic
}.
procedure data_put@pic
takes
pic pic
data unsigned
returns_nothing
#: This procedure will send {data
} to {pic
}.
procedure mask@pic
takes
pic pic
clock unsigned
data_out unsigned
enable unsigned
power unsigned
program unsigned
returns unsigned
#: This procedure will compute the mask for its arguments.
procedure mask_one@pic
takes
pic pic
configuration unsigned
value unsigned
returns unsigned
#: This procedure will will compute a mask for {configuration
} using
#, {value
}.
procedure next_read@pic
takes
pic pic
returns unsigned
#: This procedure will read the next word from {pic
} and increment
#, the address.
procedure next_write@pic
takes
pic pic
data unsigned
returns unsigned
#: This procedure will burn {data
} into the next address of {pic
}
#, and increment the address.
procedure power_down@pic
takes
pic pic
returns_nothing
#: This procedure will power down {pic
}.
procedure power_up@pic
takes
pic pic
returns_nothing
#: This procedure will power up {pic
}.