Skip to content

Commit 305a47d

Browse files
author
Boisy Pitre
committed
Adding support for FujiNet networking with new state machine approach.
1 parent ccfaa5e commit 305a47d

File tree

5 files changed

+324
-203
lines changed

5 files changed

+324
-203
lines changed

lib/bus/drivewire/drivewire.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,26 @@ int systemBus::op_cpm(std::vector<uint8_t> *q)
379379

380380
int systemBus::op_net(std::vector<uint8_t> *q)
381381
{
382+
int result = 0;
383+
int expectedResult = 1;
384+
385+
if (q->size() >= expectedResult) {
386+
int device_id = q->at(0);
387+
388+
// If device doesn't exist, create it.
389+
if (!_netDev.contains(device_id))
390+
{
391+
Debug_printf("Opening new network device %u\n",device_id);
392+
_netDev[device_id] = new drivewireNetwork(this);
393+
}
394+
395+
Debug_printv("OP_NET");
396+
Debug_printf("device = %d\n", device_id);
397+
result = _netDev[device_id]->process(q);
398+
}
399+
400+
return result;
401+
#if 0
382402
int result = 1;
383403

384404
// Get device ID
@@ -397,6 +417,7 @@ int systemBus::op_net(std::vector<uint8_t> *q)
397417
Debug_printf("OP_NET: %u\n", device_id);
398418

399419
return result;
420+
#endif
400421
}
401422

402423
int systemBus::op_unhandled(std::vector<uint8_t> *q)
@@ -876,6 +897,7 @@ int systemBus::_drivewire_process_cmd(std::vector<uint8_t> *q)
876897
dwStateMethod = &systemBus::op_fuji;
877898
break;
878899
case OP_NET:
900+
q->erase(q->begin()); // lob off OP_NET so parsing in network.cpp can go smoothly
879901
dwStateMethod = &systemBus::op_net;
880902
break;
881903
case OP_CPM:

lib/bus/drivewire/drivewire.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ class systemBus
194194
{
195195
public:
196196
int (drivewireFuji::*fnStateMethod)(std::vector<uint8_t> *);
197+
int (drivewireNetwork::*nwStateMethod)(std::vector<uint8_t> *);
197198
void resetState(void);
198199

199200
private:

lib/device/drivewire/fuji.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
drivewireFuji theFuji; // global fuji device object
3131

3232
// drivewireDisk drivewireDiskDevs[MAX_HOSTS];
33-
drivewireNetwork drivewireNetDevs[MAX_NETWORK_DEVICES];
33+
//drivewireNetwork drivewireNetDevs[MAX_NETWORK_DEVICES];
3434

3535
bool _validate_host_slot(uint8_t slot, const char *dmsg = nullptr);
3636
bool _validate_device_slot(uint8_t slot, const char *dmsg = nullptr);

0 commit comments

Comments
 (0)