3434#define DRIVEWIRE_BAUDRATE 57600
3535
3636/* Operation Codes */
37- #define OP_NOP 0
37+ #define OP_NOP 0
3838#define OP_JEFF 0xA5
3939#define OP_SERREAD ' C'
4040#define OP_SERREADM ' c'
4141#define OP_SERWRITE 0xC3
4242#define OP_SERWRITEM 0x64
43- #define OP_GETSTAT ' G'
44- #define OP_SETSTAT ' S'
45- #define OP_SERGETSTAT ' D'
46- #define OP_SERSETSTAT ' D' +128
47- #define OP_READ ' R'
48- #define OP_READEX ' R' +128
49- #define OP_WRITE ' W'
50- #define OP_REREAD ' r'
51- #define OP_REREADEX ' r' +128
52- #define OP_REWRITE ' w'
53- #define OP_INIT ' I'
54- #define OP_SERINIT ' E'
55- #define OP_SERTERM ' E' +128
43+ #define OP_GETSTAT ' G'
44+ #define OP_SETSTAT ' S'
45+ #define OP_SERGETSTAT ' D'
46+ #define OP_SERSETSTAT ' D' +128
47+ #define OP_READ ' R'
48+ #define OP_READEX ' R' +128
49+ #define OP_WRITE ' W'
50+ #define OP_REREAD ' r'
51+ #define OP_REREADEX ' r' +128
52+ #define OP_REWRITE ' w'
53+ #define OP_INIT ' I'
54+ #define OP_SERINIT ' E'
55+ #define OP_SERTERM ' E' +128
5656#define OP_DWINIT ' Z'
57- #define OP_TERM ' T'
58- #define OP_TIME ' #'
57+ #define OP_TERM ' T'
58+ #define OP_TIME ' #'
5959#define OP_RESET3 0xF8
60- #define OP_RESET2 0xFE
61- #define OP_RESET1 0xFF
62- #define OP_PRINT ' P'
63- #define OP_PRINTFLUSH ' F'
60+ #define OP_RESET2 0xFE
61+ #define OP_RESET1 0xFF
62+ #define OP_PRINT ' P'
63+ #define OP_PRINTFLUSH ' F'
6464#define OP_VPORT_READ ' C'
6565#define OP_FUJI 0xE2
6666#define OP_NET 0xE3
8282
8383// struct dwTransferData
8484// {
85- // int dw_protocol_vrsn;
86- // FILE *devpath;
87- // FILE *dskpath[4];
88- // int cocoType;
89- // int baudRate;
90- // unsigned char lastDrive;
91- // uint32_t readRetries;
92- // uint32_t writeRetries;
93- // uint32_t sectorsRead;
94- // uint32_t sectorsWritten;
95- // unsigned char lastOpcode;
96- // unsigned char lastLSN[3];
97- // unsigned char lastSector[256];
98- // unsigned char lastGetStat;
99- // unsigned char lastSetStat;
100- // uint16_t lastChecksum;
101- // unsigned char lastError;
102- // FILE *prtfp;
103- // unsigned char lastChar;
104- // char prtcmd[80];
85+ // int dw_protocol_vrsn;
86+ // FILE *devpath;
87+ // FILE *dskpath[4];
88+ // int cocoType;
89+ // int baudRate;
90+ // unsigned char lastDrive;
91+ // uint32_t readRetries;
92+ // uint32_t writeRetries;
93+ // uint32_t sectorsRead;
94+ // uint32_t sectorsWritten;
95+ // unsigned char lastOpcode;
96+ // unsigned char lastLSN[3];
97+ // unsigned char lastSector[256];
98+ // unsigned char lastGetStat;
99+ // unsigned char lastSetStat;
100+ // uint16_t lastChecksum;
101+ // unsigned char lastError;
102+ // FILE *prtfp;
103+ // unsigned char lastChar;
104+ // char prtcmd[80];
105105// };
106106
107107// EXTERN char device[256];
@@ -151,7 +151,7 @@ class virtualDevice
151151
152152 cmdFrame_t cmdFrame;
153153 bool listen_to_type3_polls = false ;
154-
154+
155155 // Optional shutdown/reboot cleanup routine
156156 virtual void shutdown (){};
157157
@@ -187,7 +187,7 @@ class systemBus
187187 IOChannel *_port = nullptr ;
188188 UARTChannel _serial;
189189 BeckerSocket _becker;
190-
190+
191191 virtualDevice *_activeDev = nullptr ;
192192 drivewireModem *_modemDev = nullptr ;
193193 drivewireFuji *_fujiDev = nullptr ;
@@ -203,6 +203,11 @@ class systemBus
203203 void _drivewire_process_cmd ();
204204 void _drivewire_process_queue ();
205205
206+ #ifdef ESP_PLATFORM
207+ void configureGPIO ();
208+ int readBaudSwitch ();
209+ #endif /* ESP_PLATFORM */
210+
206211 /* *
207212 * @brief Current Baud Rate
208213 */
@@ -329,10 +334,19 @@ class systemBus
329334 size_t write (int n) { return _port->write (n); }
330335 size_t available () { return _port->available (); }
331336 void flushOutput () { _port->flushOutput (); }
332-
337+
333338#ifdef ESP32_PLATFORM
334339 QueueHandle_t qDrivewireMessages = nullptr ;
335340#endif
341+
342+ /* BoIP things */
343+ void setHost (const char *host, int port) { _becker.setHost (host, port); }
344+ void selectSerialPort (bool useSerial) {
345+ if (useSerial)
346+ _port = &_serial;
347+ else
348+ _port = &_becker;
349+ }
336350};
337351
338352extern systemBus SYSTEM_BUS;
0 commit comments