Package drivers.ser
Class SerDriver
java.lang.Object
drivers.ser.SerDriver
The serial port driver interface. It allows for 4 different serial ports.
The association with real comm ports must be set up before this object is initialized.
As I use an outside library for this, I need to conform to that. Notably, I nerd to set the port parameters here, not from SMSQE.
That being so, I might just as well do everything from here and not from smsqe.
SMSQE ser ports come in 3 flavours : input only, output only, both. See the openingIsAllowed method for peculiarities.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate the object with no preset set of names - get the names from the machine.SerDriver
(inifile.IniFile inifile) Create the object with data to be taken from an ini file.Create the object with an existing set of names (MUST be a 4 element String array). -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkError
(MC68000Cpu cpu, int toCheck) Show SMSQE that no error occurred or not, depending ton the parameter.void
Close all ports of this driver.static void
error
(MC68000Cpu cpu, int errorCode) Show SMSQE that an error occurred: set D0 and status regs.static int
static int
getPortnumber
(MC68000Cpu cpu) Gets the port number.static List
<SerPortDefinition> void
Handle all calls from SMSQE.static void
noError
(MC68000Cpu cpu) Show SMSQE that no error occurred: simulate "CLR.L d0" : set Z flag, set D0 to 0.int
openPort
(int portNumber, MC68000Cpu cpu) Try to open the port and return success status.void
setAllPortnames2
(String[] portNames) Set the machine name for all ports.void
setDefaultParameters
(com.fazecast.jSerialComm.SerialPort serPort) Set default parameters for a port These are : 9600 bauds, 8 data bits, 1 stop bit, no parity (no flow control).final void
Set names of ports from the supplied string array.
-
Constructor Details
-
SerDriver
Create the object with an existing set of names (MUST be a 4 element String array).- Parameters:
portnames
- String array with Driver.MAX_PORTS (=4) elements (anything over that is ignored) - if this is null, empty names ("") will be created.
-
SerDriver
public SerDriver()Create the object with no preset set of names - get the names from the machine. I use the names of the serial ports present in the machine. -
SerDriver
public SerDriver(inifile.IniFile inifile) Create the object with data to be taken from an ini file.- Parameters:
inifile
- whence the data comes from.
-
-
Method Details
-
setNames
Set names of ports from the supplied string array.- Parameters:
portnames
- String array with MAX_PORTS (=4) elements (anything over that is ignored) - if this is null, empty names ("") will be created.
-
openPort
Try to open the port and return success status.- Parameters:
portNumber
- which port (0...3) to open.cpu
-- Returns:
- 0 if port opened OK, else smsqe error code.
-
handleSMSQECalls
Handle all calls from SMSQE. This sets D0 as per SMSQE code requirements.- Parameters:
cpu
- the CPU used.
-
setDefaultParameters
public void setDefaultParameters(com.fazecast.jSerialComm.SerialPort serPort) Set default parameters for a port These are : 9600 bauds, 8 data bits, 1 stop bit, no parity (no flow control).- Parameters:
serPort
-
-
error
Show SMSQE that an error occurred: set D0 and status regs.- Parameters:
cpu
-errorCode
-
-
noError
Show SMSQE that no error occurred: simulate "CLR.L d0" : set Z flag, set D0 to 0.- Parameters:
cpu
-
-
checkError
Show SMSQE that no error occurred or not, depending ton the parameter.- Parameters:
cpu
-toCheck
- return as error if this is !=0, else as no error.
-
getPortnumber
Gets the port number.- Parameters:
cpu
- whence to get the port number (at offset SPD_PORT from (a3)).- Returns:
- the port number or smsqmulator.Types.ERR_NIMP if problem.
-
getSerialPorts
- Returns:
-
closeAllPorts
public void closeAllPorts()Close all ports of this driver. -
setAllPortnames2
Set the machine name for all ports.- Parameters:
portNames
- (machine) names of the port. Should be a 4 element array, all elements beyond the fourth are ignored.
-
getMaxSerialPorts
public static int getMaxSerialPorts()
-