Package drivers.ser

Class SerDriver

java.lang.Object
drivers.ser.SerDriver

public class SerDriver extends Object
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 Details

    • SerDriver

      public SerDriver(String[] portnames)
      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

      public final void setNames(String[] portnames)
      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

      public int openPort(int portNumber, MC68000Cpu cpu)
      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

      public void handleSMSQECalls(MC68000Cpu cpu)
      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

      public static void error(MC68000Cpu cpu, int errorCode)
      Show SMSQE that an error occurred: set D0 and status regs.
      Parameters:
      cpu -
      errorCode -
    • noError

      public static void noError(MC68000Cpu cpu)
      Show SMSQE that no error occurred: simulate "CLR.L d0" : set Z flag, set D0 to 0.
      Parameters:
      cpu -
    • checkError

      public static void checkError(MC68000Cpu cpu, int toCheck)
      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

      public static int getPortnumber(MC68000Cpu cpu)
      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

      public static List<SerPortDefinition> getSerialPorts()
      Returns:
    • closeAllPorts

      public void closeAllPorts()
      Close all ports of this driver.
    • setAllPortnames2

      public void setAllPortnames2(String[] portNames)
      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()