From b6b2f81649a9b661ab0e343858e7cefe491b37d5 Mon Sep 17 00:00:00 2001 From: Chris Osborn Date: Sun, 2 Nov 2025 14:14:18 -0800 Subject: [PATCH] Standardize DEVICEID constant names. --- include/fujiDeviceID.h | 27 ++++++++++++ lib/bus/comlynx/comlynx.h | 24 +++++------ lib/bus/cx16_i2c/cx16_i2c.h | 61 +++++++--------------------- lib/bus/h89/h89.h | 22 +++++----- lib/bus/rc2014bus/rc2014bus.h | 44 +++++++------------- lib/bus/rc2014sio/rc2014sio.h | 46 +++++++-------------- lib/bus/rs232/rs232.cpp | 22 +++++----- lib/bus/rs232/rs232.h | 32 +++------------ lib/bus/sio/sio.cpp | 28 ++++++------- lib/bus/sio/sio.h | 43 +++----------------- lib/device/rs232/fuji.cpp | 9 ++-- lib/device/rs232/modem.cpp | 4 +- lib/device/sio/disk.cpp | 4 +- lib/device/sio/fuji.cpp | 13 +++--- lib/device/sio/modem.cpp | 4 +- lib/device/sio/pclink.cpp | 6 +-- lib/http/httpServiceConfigurator.cpp | 3 +- src/main.cpp | 23 ++++++----- 18 files changed, 166 insertions(+), 249 deletions(-) create mode 100644 include/fujiDeviceID.h diff --git a/include/fujiDeviceID.h b/include/fujiDeviceID.h new file mode 100644 index 000000000..68175afac --- /dev/null +++ b/include/fujiDeviceID.h @@ -0,0 +1,27 @@ +#ifndef FUJI_DEVICES_H +#define FUJI_DEVICES_H + +enum fujiDeviceID_t { + FUJI_DEVICEID_FUJINET = 0x70, + + FUJI_DEVICEID_DISK = 0x31, + FUJI_DEVICEID_DISK_LAST = 0x3F, + FUJI_DEVICEID_PRINTER = 0x40, + FUJI_DEVICEID_PRINTER_LAST = 0x43, + FUJI_DEVICEID_VOICE = 0x43, + FUJI_DEVICEID_CLOCK = 0x45, + FUJI_DEVICEID_SIO2BT_SMART = 0x45, // Doubles as APETime and "High Score Submission" to URL + FUJI_DEVICEID_ASPEQT = 0x46, + FUJI_DEVICEID_SIO2BT_NET = 0x4E, + FUJI_DEVICEID_TYPE3POLL = 0x4F, + FUJI_DEVICEID_SERIAL = 0x50, + FUJI_DEVICEID_SERIAL_LAST = 0x53, + FUJI_DEVICEID_CPM = 0x5A, + FUJI_DEVICEID_CASSETTE = 0x5F, + FUJI_DEVICEID_PCLINK = 0x6F, + FUJI_DEVICEID_NETWORK = 0x71, + FUJI_DEVICEID_NETWORK_LAST = 0x78, + FUJI_DEVICEID_MIDI = 0x99, +}; + +#endif /* FUJI_DEVICES_H */ diff --git a/lib/bus/comlynx/comlynx.h b/lib/bus/comlynx/comlynx.h index 2b17155cb..b79568029 100755 --- a/lib/bus/comlynx/comlynx.h +++ b/lib/bus/comlynx/comlynx.h @@ -174,7 +174,7 @@ class virtualDevice * @brief Do any tasks that can only be done when the bus is quiet */ virtual void comlynx_idle(); - + /** * @brief send current status of device */ @@ -189,7 +189,7 @@ class virtualDevice * @brief send status response */ virtual void comlynx_response_status(); - + /** * @brief command frame, used by network protocol, ultimately */ @@ -234,7 +234,7 @@ class virtualDevice */ uint8_t id() { return _devnum; } - + }; /** @@ -247,7 +247,7 @@ class systemBus virtualDevice *_activeDev = nullptr; lynxFuji *_fujiDev = nullptr; lynxPrinter *_printerDev = nullptr; - + void _comlynx_process_cmd(); void _comlynx_process_queue(); @@ -272,15 +272,15 @@ class systemBus //int64_t comlynx_idle_time = 1000; int numDevices(); - void addDevice(virtualDevice *pDevice, uint8_t device_id); + void addDevice(virtualDevice *pDevice, FujiDeviceID device_id); void remDevice(virtualDevice *pDevice); - void remDevice(uint8_t device_id); - bool deviceExists(uint8_t device_id); - void enableDevice(uint8_t device_id); - void disableDevice(uint8_t device_id); - virtualDevice *deviceById(uint8_t device_id); - void changeDeviceId(virtualDevice *pDevice, uint8_t device_id); - bool deviceEnabled(uint8_t device_id); + void remDevice(FujiDeviceID device_id); + bool deviceExists(FujiDeviceID device_id); + void enableDevice(FujiDeviceID device_id); + void disableDevice(FujiDeviceID device_id); + virtualDevice *deviceById(FujiDeviceID device_id); + void changeDeviceId(virtualDevice *pDevice, FujiDeviceID device_id); + bool deviceEnabled(FujiDeviceID device_id); QueueHandle_t qComlynxMessages = nullptr; void setUDPHost(const char *newhost, int port); // Set new host/ip & port for UDP Stream diff --git a/lib/bus/cx16_i2c/cx16_i2c.h b/lib/bus/cx16_i2c/cx16_i2c.h index 97e084162..3d09b4119 100644 --- a/lib/bus/cx16_i2c/cx16_i2c.h +++ b/lib/bus/cx16_i2c/cx16_i2c.h @@ -9,38 +9,7 @@ #include #include -#define CX16_DEVICEID_DISK 0x31 -#define CX16_DEVICEID_DISK_LAST 0x3F - -#define CX16_DEVICEID_PRINTER 0x40 -#define CX16_DEVICEID_PRINTER_LAST 0x43 - -#define CX16_DEVICEID_FN_VOICE 0x43 - -#define CX16_DEVICEID_APETIME 0x45 - -#define CX16_DEVICEID_TYPE3POLL 0x4F - -#define CX16_DEVICEID_RS232 0x50 -#define CX16_DEVICEID_RS2323_LAST 0x53 - -#define CX16_DEVICEID_CASSETTE 0x5F - -#define CX16_DEVICEID_FUJINET 0x70 -#define CX16_DEVICEID_FN_NETWORK 0x71 -#define CX16_DEVICEID_FN_NETWORK_LAST 0x78 - -#define CX16_DEVICEID_MIDI 0x99 - -#define CX16_DEVICEID_SIO2BT_NET 0x4E -#define CX16_DEVICEID_SIO2BT_SMART 0x45 // Doubles as APETime and "High Score Submission" to URL -#define CX16_DEVICEID_APE 0x45 -#define CX16_DEVICEID_ASPEQT 0x46 -#define CX16_DEVICEID_PCLINK 0x6F - -#define CX16_DEVICEID_CPM 0x5A - -#define I2C_SLAVE_TX_BUF_LEN 255 +#define I2C_SLAVE_TX_BUF_LEN 255 #define I2C_SLAVE_RX_BUF_LEN 32 #define I2C_DEVICE_ID 0x70 @@ -48,29 +17,29 @@ * | Address | R/W | Description * |--- |--- |--- * | 0 | W | Device ID - * | 1 | W | Command - * | 2 | W | Aux1 - * | 3 | W | Aux2 + * | 1 | W | Command + * | 2 | W | Aux1 + * | 3 | W | Aux2 * | 4 | W | Checksum of addresses 0-3 * | 5 | R | (A)CK/(N)ACK * | 6 | R | (C)OMPLETE/(E)RROR * | 7 | R/W | Payload Length (LO) * | 8 | R/W | Payload Length (HI) - * | 9 | R/W | Payload Data (auto-increment) - * + * | 9 | R/W | Payload Data (auto-increment) + * * Any write to address 0 will zero out all other addresses. * Read to address 0 to perform command - * + * * So the sequence to perform a command to the fujinet: - * + * * 1. Write addresses 0-4 for command frame. * 2. if a write payload is needed, write length lo/hi, then write payload data for # of bytes in length * 3. READ from address 0 to perform command. * 4. Check ACK/NAK * 5. Check COMPLETE/ERROR - * + * * Alternatively, to perform a command from fujinet to the CX16: - * + * * 1. Write addresses 0-4 for the command frame. * 2. If a read payload is expected, write length lo/hi. * 3. READ from address 0 to perform command. @@ -129,7 +98,7 @@ class virtualDevice /** * @brief The passed in command frame, copied. */ - cmdFrame_t cmdFrame; + cmdFrame_t cmdFrame; /** * @brief Message queue @@ -337,7 +306,7 @@ class systemBus * @param pDevice Pointer to virtualDevice * @param device_id The ID to assign to virtualDevice */ - void addDevice(virtualDevice *pDevice, int device_id); + void addDevice(virtualDevice *pDevice, FujiDeviceID device_id); /** * @brief Remove device from bus @@ -350,14 +319,14 @@ class systemBus * @param device_id ID of device to return. * @return pointer to virtualDevice */ - virtualDevice *deviceById(int device_id); + virtualDevice *deviceById(FujiDeviceID device_id); /** * @brief Change ID of a particular virtualDevice * @param pDevice pointer to virtualDevice - * @param device_id new device ID + * @param device_id new device ID */ - void changeDeviceId(virtualDevice *pDevice, int device_id); + void changeDeviceId(virtualDevice *pDevice, FujiDeviceID device_id); /** * @brief Are we shutting down? diff --git a/lib/bus/h89/h89.h b/lib/bus/h89/h89.h index 54df9f696..3c8a5b850 100644 --- a/lib/bus/h89/h89.h +++ b/lib/bus/h89/h89.h @@ -56,11 +56,11 @@ class virtualDevice virtual void reset() {}; /** - * @brief All H89 devices repeatedly call this routine to fan out to other methods for each command. + * @brief All H89 devices repeatedly call this routine to fan out to other methods for each command. * This is typcially implemented as a switch() statement. */ virtual void process(uint32_t commanddata, uint8_t checksum) = 0; - + /** * @brief send current status of device */ @@ -97,20 +97,20 @@ class systemBus public: void setup(); // one time setup - void service(); // this runs in a loop + void service(); // this runs in a loop void shutdown(); // shutdown void reset(); // reset int numDevices(); - void addDevice(virtualDevice *pDevice, uint8_t device_id); + void addDevice(virtualDevice *pDevice, FujiDeviceID device_id); void remDevice(virtualDevice *pDevice); - void remDevice(uint8_t device_id); - bool deviceExists(uint8_t device_id); - void enableDevice(uint8_t device_id); - void disableDevice(uint8_t device_id); - bool enabledDeviceStatus(uint8_t device_id); - virtualDevice *deviceById(uint8_t device_id); - void changeDeviceId(virtualDevice *pDevice, uint8_t device_id); + void remDevice(FujiDeviceID device_id); + bool deviceExists(FujiDeviceID device_id); + void enableDevice(FujiDeviceID device_id); + void disableDevice(FujiDeviceID device_id); + bool enabledDeviceStatus(FujiDeviceID device_id); + virtualDevice *deviceById(FujiDeviceID device_id); + void changeDeviceId(virtualDevice *pDevice, FujiDeviceID device_id); QueueHandle_t qH89Messages = nullptr; bool shuttingDown = false; // TRUE if we are in shutdown process diff --git a/lib/bus/rc2014bus/rc2014bus.h b/lib/bus/rc2014bus/rc2014bus.h index 80548ae88..f307a4fd2 100644 --- a/lib/bus/rc2014bus/rc2014bus.h +++ b/lib/bus/rc2014bus/rc2014bus.h @@ -17,22 +17,6 @@ #define RC2014SIO_BAUDRATE 115200 -#define RC2014_DEVICEID_DISK 0x31 -#define RC2014_DEVICEID_DISK_LAST 0x3F - -#define RC2014_DEVICEID_PRINTER 0x41 -#define RC2014_DEVICEID_PRINTER_LAST 0x44 - - -#define RC2014_DEVICEID_FUJINET 0x70 -#define RC2014_DEVICEID_FN_NETWORK 0x71 -#define RC2014_DEVICEID_FN_NETWORK_LAST 0x78 - -#define RC2014_DEVICEID_MODEM 0x50 - -#define RC2014_DEVICEID_CPM 0x5A - - #define rc2014_RESET_DEBOUNCE_PERIOD 100 // in ms constexpr int RC2014_TX_BUFFER_SIZE = 1024; @@ -217,7 +201,7 @@ class virtualDevice */ uint8_t rc2014_recv(); - /** + /** * How many bytes available? */ int rc2014_recv_available(); @@ -296,7 +280,7 @@ class virtualDevice virtual void shutdown() {} /** - * @brief All RS232 devices repeatedly call this routine to fan out to other methods for each command. + * @brief All RS232 devices repeatedly call this routine to fan out to other methods for each command. * This is typcially implemented as a switch() statement. */ virtual void rc2014_process(uint32_t commanddata, uint8_t checksum) = 0; @@ -305,7 +289,7 @@ class virtualDevice * @brief Do any tasks that can only be done when the bus is quiet */ virtual void rc2014_idle(); - + /** * @brief send current status of device */ @@ -315,7 +299,7 @@ class virtualDevice * @brief send status response */ virtual void rc2014_response_status(); - + /** * @brief handle the uart stream when not used for command */ @@ -325,7 +309,7 @@ class virtualDevice * @brief poll device to see if an interrupt needs to be raised */ virtual bool rc2014_poll_interrupt(); - + /** * @brief command frame, used by network protocol, ultimately @@ -395,17 +379,17 @@ class systemBus int64_t start_time; int numDevices(); - void addDevice(virtualDevice *pDevice, uint8_t device_id); + void addDevice(virtualDevice *pDevice, FujiDeviceID device_id); void remDevice(virtualDevice *pDevice); - void remDevice(uint8_t device_id); - bool deviceExists(uint8_t device_id); - void enableDevice(uint8_t device_id); - void disableDevice(uint8_t device_id); - bool enabledDeviceStatus(uint8_t device_id); - void streamDevice(uint8_t device_id); + void remDevice(FujiDeviceID device_id); + bool deviceExists(FujiDeviceID device_id); + void enableDevice(FujiDeviceID device_id); + void disableDevice(FujiDeviceID device_id); + bool enabledDeviceStatus(FujiDeviceID device_id); + void streamDevice(FujiDeviceID device_id); void streamDeactivate(); - virtualDevice *deviceById(uint8_t device_id); - void changeDeviceId(virtualDevice *pDevice, uint8_t device_id); + virtualDevice *deviceById(FujiDeviceID device_id); + void changeDeviceId(virtualDevice *pDevice, FujiDeviceID device_id); QueueHandle_t qrc2014Messages = nullptr; bool shuttingDown = false; // TRUE if we are in shutdown process diff --git a/lib/bus/rc2014sio/rc2014sio.h b/lib/bus/rc2014sio/rc2014sio.h index 57ffc341c..c367fed46 100644 --- a/lib/bus/rc2014sio/rc2014sio.h +++ b/lib/bus/rc2014sio/rc2014sio.h @@ -12,22 +12,6 @@ #define RC2014SIO_BAUDRATE 115200 -#define RC2014_DEVICEID_DISK 0x31 -#define RC2014_DEVICEID_DISK_LAST 0x3F - -#define RC2014_DEVICEID_PRINTER 0x41 -#define RC2014_DEVICEID_PRINTER_LAST 0x44 - - -#define RC2014_DEVICEID_FUJINET 0x70 -#define RC2014_DEVICEID_FN_NETWORK 0x71 -#define RC2014_DEVICEID_FN_NETWORK_LAST 0x78 - -#define RC2014_DEVICEID_MODEM 0x50 - -#define RC2014_DEVICEID_CPM 0x5A - - #define rc2014_RESET_DEBOUNCE_PERIOD 100 // in ms union cmdFrame_t @@ -109,7 +93,7 @@ class virtualDevice */ uint8_t rc2014_recv(); - /** + /** * How many bytes available? */ int rc2014_recv_available(); @@ -185,7 +169,7 @@ class virtualDevice virtual void shutdown() {} /** - * @brief All RS232 devices repeatedly call this routine to fan out to other methods for each command. + * @brief All RS232 devices repeatedly call this routine to fan out to other methods for each command. * This is typcially implemented as a switch() statement. */ virtual void rc2014_process(uint32_t commanddata, uint8_t checksum) = 0; @@ -194,7 +178,7 @@ class virtualDevice * @brief Do any tasks that can only be done when the bus is quiet */ virtual void rc2014_idle(); - + /** * @brief send current status of device */ @@ -204,12 +188,12 @@ class virtualDevice * @brief send status response */ virtual void rc2014_response_status(); - + /** * @brief handle the uart stream when not used for command */ virtual void rc2014_handle_stream(); - + /** * @brief command frame, used by network protocol, ultimately */ @@ -238,7 +222,7 @@ class virtualDevice */ uint8_t id() { return _devnum; } - + }; /** @@ -270,17 +254,17 @@ class systemBus int64_t start_time; int numDevices(); - void addDevice(virtualDevice *pDevice, uint8_t device_id); + void addDevice(virtualDevice *pDevice, FujiDeviceID device_id); void remDevice(virtualDevice *pDevice); - void remDevice(uint8_t device_id); - bool deviceExists(uint8_t device_id); - void enableDevice(uint8_t device_id); - void disableDevice(uint8_t device_id); - bool enabledDeviceStatus(uint8_t device_id); - void streamDevice(uint8_t device_id); + void remDevice(FujiDeviceID device_id); + bool deviceExists(FujiDeviceID device_id); + void enableDevice(FujiDeviceID device_id); + void disableDevice(FujiDeviceID device_id); + bool enabledDeviceStatus(FujiDeviceID device_id); + void streamDevice(FujiDeviceID device_id); void streamDeactivate(); - virtualDevice *deviceById(uint8_t device_id); - void changeDeviceId(virtualDevice *pDevice, uint8_t device_id); + virtualDevice *deviceById(FujiDeviceID device_id); + void changeDeviceId(virtualDevice *pDevice, FujiDeviceID device_id); QueueHandle_t qrc2014Messages = nullptr; bool shuttingDown = false; // TRUE if we are in shutdown process diff --git a/lib/bus/rs232/rs232.cpp b/lib/bus/rs232/rs232.cpp index 102dfa52a..162debe5e 100755 --- a/lib/bus/rs232/rs232.cpp +++ b/lib/bus/rs232/rs232.cpp @@ -200,7 +200,7 @@ void systemBus::_rs232_process_cmd() uint8_t ck = rs232_checksum((uint8_t *)&tempFrame, sizeof(tempFrame) - sizeof(tempFrame.cksum)); // Calculate Checksum if (ck == tempFrame.cksum) { - if (tempFrame.device == RS232_DEVICEID_DISK && _fujiDev != nullptr && _fujiDev->boot_config) + if (tempFrame.device == FUJI_DEVICEID_DISK && _fujiDev != nullptr && _fujiDev->boot_config) { _activeDev = _fujiDev->bootdisk(); @@ -327,29 +327,29 @@ void systemBus::setup() } // Add device to RS232 bus -void systemBus::addDevice(virtualDevice *pDevice, int device_id) +void systemBus::addDevice(virtualDevice *pDevice, fujiDeviceID_t device_id) { - if (device_id == RS232_DEVICEID_FUJINET) + if (device_id == FUJI_DEVICEID_FUJINET) { _fujiDev = (rs232Fuji *)pDevice; } - else if (device_id == RS232_DEVICEID_RS232) + else if (device_id == FUJI_DEVICEID_SERIAL) { _modemDev = (rs232Modem *)pDevice; } - else if (device_id >= RS232_DEVICEID_FN_NETWORK && device_id <= RS232_DEVICEID_FN_NETWORK_LAST) + else if (device_id >= FUJI_DEVICEID_NETWORK && device_id <= FUJI_DEVICEID_NETWORK_LAST) { - _netDev[device_id - RS232_DEVICEID_FN_NETWORK] = (rs232Network *)pDevice; + _netDev[device_id - FUJI_DEVICEID_NETWORK] = (rs232Network *)pDevice; } - else if (device_id == RS232_DEVICEID_MIDI) + else if (device_id == FUJI_DEVICEID_MIDI) { _udpDev = (rs232UDPStream *)pDevice; } - else if (device_id == RS232_DEVICEID_CPM) + else if (device_id == FUJI_DEVICEID_CPM) { _cpmDev = (rs232CPM *)pDevice; } - else if (device_id == RS232_DEVICEID_PRINTER) + else if (device_id == FUJI_DEVICEID_PRINTER) { _printerdev = (rs232Printer *)pDevice; } @@ -377,7 +377,7 @@ int systemBus::numDevices() __END_IGNORE_UNUSEDVARS } -void systemBus::changeDeviceId(virtualDevice *p, int device_id) +void systemBus::changeDeviceId(virtualDevice *p, fujiDeviceID_t device_id) { for (auto devicep : _daisyChain) { @@ -386,7 +386,7 @@ void systemBus::changeDeviceId(virtualDevice *p, int device_id) } } -virtualDevice *systemBus::deviceById(int device_id) +virtualDevice *systemBus::deviceById(fujiDeviceID_t device_id) { for (auto devicep : _daisyChain) { diff --git a/lib/bus/rs232/rs232.h b/lib/bus/rs232/rs232.h index f3aa21330..93f3e00f5 100755 --- a/lib/bus/rs232/rs232.h +++ b/lib/bus/rs232/rs232.h @@ -2,6 +2,7 @@ #define RS232_H #include "UARTChannel.h" +#include "fujiDeviceID.h" #ifdef ESP_PLATFORM #include @@ -13,27 +14,6 @@ #define RS232_BAUDRATE 9600 //#define RS232_BAUDRATE 115200 -#define RS232_DEVICEID_DISK 0x31 -#define RS232_DEVICEID_DISK_LAST 0x3F - -#define RS232_DEVICEID_PRINTER 0x40 -#define RS232_DEVICEID_PRINTER_LAST 0x43 - -#define RS232_DEVICEID_FN_VOICE 0x43 - -#define RS232_DEVICEID_APETIME 0x45 - -#define RS232_DEVICEID_RS232 0x50 -#define RS232_DEVICEID_RS2323_LAST 0x53 - -#define RS232_DEVICEID_FUJINET 0x70 -#define RS232_DEVICEID_FN_NETWORK 0x71 -#define RS232_DEVICEID_FN_NETWORK_LAST 0x78 - -#define RS232_DEVICEID_MIDI 0x99 - -#define RS232_DEVICEID_CPM 0x5A - #define DELAY_T4 800 #define DELAY_T5 800 @@ -79,7 +59,7 @@ class virtualDevice protected: friend systemBus; - int _devnum; + fujiDeviceID_t _devnum; cmdFrame_t cmdFrame; bool listen_to_type3_polls = false; @@ -161,7 +141,7 @@ class virtualDevice * @brief get the RS232 device Number (1-255) * @return The device number registered for this device */ - int id() { return _devnum; }; + fujiDeviceID_t id() { return _devnum; }; /** * @brief Command 0x3F '?' intended to return a single byte to the atari via bus_to_computer(), which @@ -235,10 +215,10 @@ class systemBus void shutdown(); int numDevices(); - void addDevice(virtualDevice *pDevice, int device_id); + void addDevice(virtualDevice *pDevice, fujiDeviceID_t device_id); void remDevice(virtualDevice *pDevice); - virtualDevice *deviceById(int device_id); - void changeDeviceId(virtualDevice *pDevice, int device_id); + virtualDevice *deviceById(fujiDeviceID_t device_id); + void changeDeviceId(virtualDevice *pDevice, fujiDeviceID_t device_id); int getBaudrate(); // Gets current RS232 baud rate setting void setBaudrate(int baud); // Sets RS232 to specific baud rate diff --git a/lib/bus/sio/sio.cpp b/lib/bus/sio/sio.cpp index 0bb6817ed..418431e21 100755 --- a/lib/bus/sio/sio.cpp +++ b/lib/bus/sio/sio.cpp @@ -254,7 +254,7 @@ void systemBus::_sio_process_cmd() // reset counter if checksum was correct _command_frame_counter = 0; #endif - if (tempFrame.device == SIO_DEVICEID_DISK && _fujiDev != nullptr && _fujiDev->boot_config) + if (tempFrame.device == FUJI_DEVICEID_DISK && _fujiDev != nullptr && _fujiDev->boot_config) { _activeDev = _fujiDev->bootdisk(); if (_activeDev->status_wait_count > 0 && tempFrame.comnd == 'R' && _fujiDev->status_wait_enabled) @@ -272,8 +272,8 @@ void systemBus::_sio_process_cmd() } else { - // Command SIO_DEVICEID_TYPE3POLL is a Type3 poll - send it to every device that cares - if (tempFrame.device == SIO_DEVICEID_TYPE3POLL) + // Command FUJI_DEVICEID_TYPE3POLL is a Type3 poll - send it to every device that cares + if (tempFrame.device == FUJI_DEVICEID_TYPE3POLL) { Debug_println("SIO TYPE3 POLL"); for (auto devicep : _daisyChain) @@ -538,33 +538,33 @@ void systemBus::setup() } // Add device to SIO bus -void systemBus::addDevice(virtualDevice *pDevice, int device_id) +void systemBus::addDevice(virtualDevice *pDevice, fujiDeviceID_t device_id) { - if (device_id == SIO_DEVICEID_FUJINET) + if (device_id == FUJI_DEVICEID_FUJINET) { _fujiDev = (sioFuji *)pDevice; } - else if (device_id == SIO_DEVICEID_RS232) + else if (device_id == FUJI_DEVICEID_SERIAL) { _modemDev = (modem *)pDevice; } - else if (device_id >= SIO_DEVICEID_FN_NETWORK && device_id <= SIO_DEVICEID_FN_NETWORK_LAST) + else if (device_id >= FUJI_DEVICEID_NETWORK && device_id <= FUJI_DEVICEID_NETWORK_LAST) { - _netDev[device_id - SIO_DEVICEID_FN_NETWORK] = (sioNetwork *)pDevice; + _netDev[device_id - FUJI_DEVICEID_NETWORK] = (sioNetwork *)pDevice; } - else if (device_id == SIO_DEVICEID_MIDI) + else if (device_id == FUJI_DEVICEID_MIDI) { _udpDev = (sioUDPStream *)pDevice; } - else if (device_id == SIO_DEVICEID_CASSETTE) + else if (device_id == FUJI_DEVICEID_CASSETTE) { _cassetteDev = (sioCassette *)pDevice; } - else if (device_id == SIO_DEVICEID_CPM) + else if (device_id == FUJI_DEVICEID_CPM) { _cpmDev = (sioCPM *)pDevice; } - else if (device_id == SIO_DEVICEID_PRINTER) + else if (device_id == FUJI_DEVICEID_PRINTER) { _printerdev = (sioPrinter *)pDevice; } @@ -592,7 +592,7 @@ int systemBus::numDevices() __END_IGNORE_UNUSEDVARS } -void systemBus::changeDeviceId(virtualDevice *p, int device_id) +void systemBus::changeDeviceId(virtualDevice *p, fujiDeviceID_t device_id) { for (auto devicep : _daisyChain) { @@ -601,7 +601,7 @@ void systemBus::changeDeviceId(virtualDevice *p, int device_id) } } -virtualDevice *systemBus::deviceById(int device_id) +virtualDevice *systemBus::deviceById(fujiDeviceID_t device_id) { for (auto devicep : _daisyChain) { diff --git a/lib/bus/sio/sio.h b/lib/bus/sio/sio.h index fa63f767c..020204e3f 100755 --- a/lib/bus/sio/sio.h +++ b/lib/bus/sio/sio.h @@ -3,6 +3,7 @@ #include "UARTChannel.h" #include "NetSIO.h" +#include "fujiDeviceID.h" #include #define DELAY_T4 850 @@ -50,38 +51,6 @@ FN_HISPEED_INDEX=40 // 18,806 (18,806) baud #define COMMAND_FRAME_SPEED_CHANGE_THRESHOLD 2 #define SERIAL_TIMEOUT 300 -#define SIO_DEVICEID_DISK 0x31 -#define SIO_DEVICEID_DISK_LAST 0x3F - -#define SIO_DEVICEID_PRINTER 0x40 -#define SIO_DEVICEID_PRINTER_LAST 0x43 - -#define SIO_DEVICEID_FN_VOICE 0x43 - -#define SIO_DEVICEID_APETIME 0x45 - -#define SIO_DEVICEID_TYPE3POLL 0x4F - -#define SIO_DEVICEID_RS232 0x50 -#define SIO_DEVICEID_RS2323_LAST 0x53 - -#define SIO_DEVICEID_CASSETTE 0x5F - -#define SIO_DEVICEID_FUJINET 0x70 -#define SIO_DEVICEID_FN_NETWORK 0x71 -#define SIO_DEVICEID_FN_NETWORK_LAST 0x78 - -#define SIO_DEVICEID_MIDI 0x99 - -// Not used, but for reference: -#define SIO_DEVICEID_SIO2BT_NET 0x4E -#define SIO_DEVICEID_SIO2BT_SMART 0x45 // Doubles as APETime and "High Score Submission" to URL -#define SIO_DEVICEID_APE 0x45 -#define SIO_DEVICEID_ASPEQT 0x46 -#define SIO_DEVICEID_PCLINK 0x6F - -#define SIO_DEVICEID_CPM 0x5A - union cmdFrame_t { struct @@ -117,7 +86,7 @@ class virtualDevice protected: friend systemBus; - int _devnum; + fujiDeviceID_t _devnum; cmdFrame_t cmdFrame; bool listen_to_type3_polls = false; @@ -208,7 +177,7 @@ class virtualDevice * @brief get the SIO device Number (1-255) * @return The device number registered for this device */ - int id() { return _devnum; }; + fujiDeviceID_t id() { return _devnum; }; /** * @brief Command 0x3F '?' intended to return a single byte to the atari via bus_to_computer(), which @@ -289,10 +258,10 @@ class systemBus void shutdown(); int numDevices(); - void addDevice(virtualDevice *pDevice, int device_id); + void addDevice(virtualDevice *pDevice, fujiDeviceID_t device_id); void remDevice(virtualDevice *pDevice); - virtualDevice *deviceById(int device_id); - void changeDeviceId(virtualDevice *pDevice, int device_id); + virtualDevice *deviceById(fujiDeviceID_t device_id); + void changeDeviceId(virtualDevice *pDevice, fujiDeviceID_t device_id); int getBaudrate(); // Gets current SIO baud rate setting void setBaudrate(int baud); // Sets SIO to specific baud rate diff --git a/lib/device/rs232/fuji.cpp b/lib/device/rs232/fuji.cpp index 878d4dc60..657c675b9 100755 --- a/lib/device/rs232/fuji.cpp +++ b/lib/device/rs232/fuji.cpp @@ -742,11 +742,11 @@ void rs232Fuji::image_rotate() count--; // Save the device ID of the disk in the last slot - int last_id = _fnDisks[count].disk_dev.id(); + fujiDeviceID_t last_id = _fnDisks[count].disk_dev.id(); for (int n = count; n > 0; n--) { - int swap = _fnDisks[n - 1].disk_dev.id(); + fujiDeviceID_t swap = _fnDisks[n - 1].disk_dev.id(); Debug_printf("setting slot %d to ID %hx\n", n, swap); SYSTEM_BUS.changeDeviceId(&_fnDisks[n].disk_dev, swap); } @@ -1473,10 +1473,11 @@ void rs232Fuji::setup() // Add our devices to the RS232 bus for (int i = 0; i < MAX_DISK_DEVICES; i++) - SYSTEM_BUS.addDevice(&_fnDisks[i].disk_dev, RS232_DEVICEID_DISK + i); + SYSTEM_BUS.addDevice(&_fnDisks[i].disk_dev, (fujiDeviceID_t) (FUJI_DEVICEID_DISK + i)); for (int i = 0; i < MAX_NETWORK_DEVICES; i++) - SYSTEM_BUS.addDevice(&rs232NetDevs[i], RS232_DEVICEID_FN_NETWORK + i); + SYSTEM_BUS.addDevice(&rs232NetDevs[i], + (fujiDeviceID_t) (FUJI_DEVICEID_NETWORK + i)); } diff --git a/lib/device/rs232/modem.cpp b/lib/device/rs232/modem.cpp index c945c98ea..6ad1e131d 100755 --- a/lib/device/rs232/modem.cpp +++ b/lib/device/rs232/modem.cpp @@ -151,7 +151,7 @@ void rs232Modem::rs232_poll_3(uint8_t device, uint8_t aux1, uint8_t aux2) return; } // When AUX1 = 0x52 'R' and AUX == 1 or DEVICE == x050, it's a directed poll to "R1:" - if ((aux1 == 0x52 && aux2 == 0x01) || device == RS232_DEVICEID_RS232) + if ((aux1 == 0x52 && aux2 == 0x01) || device == FUJI_DEVICEID_SERIAL) { Debug_print("MODEM TYPE 4 \"R1:\" DIRECTED POLL\n"); respond = true; @@ -176,7 +176,7 @@ void rs232Modem::rs232_poll_3(uint8_t device, uint8_t aux1, uint8_t aux2) uint8_t type4response[4]; type4response[0] = LOBYTE_FROM_UINT16(fsize); type4response[1] = HIBYTE_FROM_UINT16(fsize); - type4response[2] = RS232_DEVICEID_RS232; + type4response[2] = FUJI_DEVICEID_SERIAL; type4response[3] = 0; fnSystem.delay_microseconds(DELAY_FIRMWARE_DELIVERY); diff --git a/lib/device/sio/disk.cpp b/lib/device/sio/disk.cpp index 92904971b..b185a912a 100755 --- a/lib/device/sio/disk.cpp +++ b/lib/device/sio/disk.cpp @@ -126,7 +126,7 @@ void sioDisk::sio_status() uint8_t _status[4]; _status[0] = 0x00; - + if (_disk != nullptr) { if (_disk->_disk_num_sectors == 1040) @@ -319,7 +319,7 @@ void sioDisk::sio_process(uint32_t commanddata, uint8_t checksum) if (_disk == nullptr || _disk->_disktype == MEDIATYPE_UNKNOWN) return; - if ((device_active == false && cmdFrame.device != SIO_DEVICEID_DISK) || // not active and not D1 + if ((device_active == false && cmdFrame.device != FUJI_DEVICEID_DISK) || // not active and not D1 (device_active == false && theFuji.boot_config == false)) // not active and not config boot return; diff --git a/lib/device/sio/fuji.cpp b/lib/device/sio/fuji.cpp index 31a86abd7..cb421ea57 100644 --- a/lib/device/sio/fuji.cpp +++ b/lib/device/sio/fuji.cpp @@ -1068,11 +1068,11 @@ void sioFuji::image_rotate() count--; // Save the device ID of the disk in the last slot - int last_id = _fnDisks[count].disk_dev.id(); + fujiDeviceID_t last_id = _fnDisks[count].disk_dev.id(); for (int n = count; n > 0; n--) { - int swap = _fnDisks[n - 1].disk_dev.id(); + fujiDeviceID_t swap = _fnDisks[n - 1].disk_dev.id(); Debug_printf("setting slot %d to ID %x\n", n, swap); SYSTEM_BUS.changeDeviceId(&_fnDisks[n].disk_dev, swap); } @@ -2060,7 +2060,7 @@ void sioFuji::insert_boot_device(uint8_t d) return; } } - + Debug_printf("opening lobby.\n"); fBoot = fnTNFS.fnfile_open("/ATARI/_lobby.xex"); _bootDisk.mount(fBoot, "/ATARI/_lobby.xex", 0); @@ -2172,12 +2172,13 @@ void sioFuji::setup() // Add our devices to the SIO bus for (int i = 0; i < MAX_DISK_DEVICES; i++) - SYSTEM_BUS.addDevice(&_fnDisks[i].disk_dev, SIO_DEVICEID_DISK + i); + SYSTEM_BUS.addDevice(&_fnDisks[i].disk_dev, (fujiDeviceID_t) (FUJI_DEVICEID_DISK + i)); for (int i = 0; i < MAX_NETWORK_DEVICES; i++) - SYSTEM_BUS.addDevice(sioNetDevs[i].get(), SIO_DEVICEID_FN_NETWORK + i); + SYSTEM_BUS.addDevice(sioNetDevs[i].get(), + (fujiDeviceID_t) (FUJI_DEVICEID_NETWORK + i)); - SYSTEM_BUS.addDevice(&_cassetteDev, SIO_DEVICEID_CASSETTE); + SYSTEM_BUS.addDevice(&_cassetteDev, FUJI_DEVICEID_CASSETTE); cassette()->set_buttons(Config.get_cassette_buttons()); cassette()->set_pulldown(Config.get_cassette_pulldown()); } diff --git a/lib/device/sio/modem.cpp b/lib/device/sio/modem.cpp index 5e4b33c7a..bf7449989 100755 --- a/lib/device/sio/modem.cpp +++ b/lib/device/sio/modem.cpp @@ -151,7 +151,7 @@ void modem::sio_poll_3(uint8_t device, uint8_t aux1, uint8_t aux2) return; } // When AUX1 = 0x52 'R' and AUX == 1 or DEVICE == x050, it's a directed poll to "R1:" - if ((aux1 == 0x52 && aux2 == 0x01) || device == SIO_DEVICEID_RS232) + if ((aux1 == 0x52 && aux2 == 0x01) || device == FUJI_DEVICEID_SERIAL) { Debug_print("MODEM TYPE 4 \"R1:\" DIRECTED POLL\n"); respond = true; @@ -176,7 +176,7 @@ void modem::sio_poll_3(uint8_t device, uint8_t aux1, uint8_t aux2) uint8_t type4response[4]; type4response[0] = LOBYTE_FROM_UINT16(fsize); type4response[1] = HIBYTE_FROM_UINT16(fsize); - type4response[2] = SIO_DEVICEID_RS232; + type4response[2] = FUJI_DEVICEID_SERIAL; type4response[3] = 0; fnSystem.delay_microseconds(DELAY_FIRMWARE_DELIVERY); diff --git a/lib/device/sio/pclink.cpp b/lib/device/sio/pclink.cpp index c0399dff4..bbda5350a 100644 --- a/lib/device/sio/pclink.cpp +++ b/lib/device/sio/pclink.cpp @@ -710,7 +710,7 @@ do_pclink_init(int server_cold_start) device[unit].status.stat = 0; device[unit].status.err = 1; device[unit].status.tmot = 0; - device[unit].status.none = SIO_DEVICEID_PCLINK; + device[unit].status.none = FUJI_DEVICEID_PCLINK; } } } @@ -1467,7 +1467,7 @@ do_pclink(uchar devno, uchar ccom, uchar caux1, uchar caux2) do_pclink_init(0); device[cunit].parbuf.handle = 0xff; - device[cunit].status.none = SIO_DEVICEID_PCLINK; + device[cunit].status.none = FUJI_DEVICEID_PCLINK; device[cunit].status.err = 1; goto complete; } @@ -2668,7 +2668,7 @@ void sioPCLink::sio_process(uint32_t commanddata, uint8_t checksum) cmdFrame.checksum = checksum; uchar cunit = cmdFrame.aux2 & 0x0f; /* PCLink ignores DUNIT */ - uchar cdev = SIO_DEVICEID_PCLINK; + uchar cdev = FUJI_DEVICEID_PCLINK; uchar devno = cdev >> 4; // ??? magical 6 if (!Config.get_pclink_enabled()) diff --git a/lib/http/httpServiceConfigurator.cpp b/lib/http/httpServiceConfigurator.cpp index 28513ffe9..b7919df2e 100644 --- a/lib/http/httpServiceConfigurator.cpp +++ b/lib/http/httpServiceConfigurator.cpp @@ -442,7 +442,8 @@ void fnHttpServiceConfigurator::config_printer_port(std::string printernumber, s fnPrinters.set_port(0, port); #ifdef BUILD_ATARI // Tell the SIO daisy chain to change the device ID for this printer - SYSTEM_BUS.changeDeviceId(fnPrinters.get_ptr(0), SIO_DEVICEID_PRINTER + port); + SYSTEM_BUS.changeDeviceId(fnPrinters.get_ptr(0), + (fujiDeviceID_t) (FUJI_DEVICEID_PRINTER + port)); #endif Config.save(); diff --git a/src/main.cpp b/src/main.cpp index 56f6d35f8..b755a95aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -238,13 +238,13 @@ void main_setup(int argc, char *argv[]) #ifdef BUILD_ATARI theFuji.setup(); - SYSTEM_BUS.addDevice(&theFuji, SIO_DEVICEID_FUJINET); // the FUJINET! + SYSTEM_BUS.addDevice(&theFuji, FUJI_DEVICEID_FUJINET); // the FUJINET! if (Config.get_apetime_enabled() == true) - SYSTEM_BUS.addDevice(&clockDevice, SIO_DEVICEID_APETIME); // Clock for Atari, APETime compatible, but extended for additional return types + SYSTEM_BUS.addDevice(&clockDevice, FUJI_DEVICEID_CLOCK); // Clock for Atari, APETime compatible, but extended for additional return types #ifdef ESP_PLATFORM - SYSTEM_BUS.addDevice(&udpDev, SIO_DEVICEID_MIDI); // UDP/MIDI device + SYSTEM_BUS.addDevice(&udpDev, FUJI_DEVICEID_MIDI); // UDP/MIDI device #endif // add PCLink device only if we have SD card @@ -256,7 +256,7 @@ void main_setup(int argc, char *argv[]) #else pcLink.mount(1, Config.get_general_SD_path().c_str()); // mount SD as PCL1: #endif - SYSTEM_BUS.addDevice(&pcLink, SIO_DEVICEID_PCLINK); // PCLink + SYSTEM_BUS.addDevice(&pcLink, FUJI_DEVICEID_PCLINK); // PCLink } // Create a new printer object, setting its output depending on whether we have SD or not @@ -270,15 +270,16 @@ void main_setup(int argc, char *argv[]) sioPrinter *ptr = new sioPrinter(ptrfs, ptype); fnPrinters.set_entry(0, ptr, ptype, Config.get_printer_port(0)); - SYSTEM_BUS.addDevice(ptr, SIO_DEVICEID_PRINTER + fnPrinters.get_port(0)); // P: + SYSTEM_BUS.addDevice(ptr, (fujiDeviceID_t) (FUJI_DEVICEID_PRINTER + + fnPrinters.get_port(0))); // P: sioR = new modem(ptrfs, Config.get_modem_sniffer_enabled()); // Config/User selected sniffer enable - SYSTEM_BUS.addDevice(sioR, SIO_DEVICEID_RS232); // R: + SYSTEM_BUS.addDevice(sioR, FUJI_DEVICEID_SERIAL); // R: - SYSTEM_BUS.addDevice(&sioV, SIO_DEVICEID_FN_VOICE); // P3: + SYSTEM_BUS.addDevice(&sioV, FUJI_DEVICEID_VOICE); // P3: - SYSTEM_BUS.addDevice(&sioZ, SIO_DEVICEID_CPM); // (ATR8000 CPM) + SYSTEM_BUS.addDevice(&sioZ, FUJI_DEVICEID_CPM); // (ATR8000 CPM) // Go setup SIO SYSTEM_BUS.setup(); @@ -319,9 +320,9 @@ void main_setup(int argc, char *argv[]) #ifdef BUILD_RS232 theFuji.setup(); SYSTEM_BUS.setup(); - SYSTEM_BUS.addDevice(&theFuji,0x70); + SYSTEM_BUS.addDevice(&theFuji, FUJI_DEVICEID_FUJINET); if (Config.get_apetime_enabled() == true) - SYSTEM_BUS.addDevice(&apeTime, RS232_DEVICEID_APETIME); // Clock for Atari, APETime compatible, but extended for additional return types + SYSTEM_BUS.addDevice(&apeTime, FUJI_DEVICEID_CLOCK); // Clock for Atari, APETime compatible, but extended for additional return types // Create a new printer object, setting its output depending on whether we have SD or not FileSystem *ptrfs = fnSDFAT.running() ? (FileSystem *)&fnSDFAT : (FileSystem *)&fsFlash; @@ -334,7 +335,7 @@ void main_setup(int argc, char *argv[]) rs232Printer *ptr = new rs232Printer(ptrfs, ptype); fnPrinters.set_entry(0, ptr, ptype, 0); - SYSTEM_BUS.addDevice(ptr, RS232_DEVICEID_PRINTER); // P: + SYSTEM_BUS.addDevice(ptr, FUJI_DEVICEID_PRINTER); // P: #endif #ifdef BUILD_RC2014