Skip to content

Commit 0f21d24

Browse files
Lynx firmware cleanup and regresssion fix (#1249)
Cleanup of commented out and also unused code. Fixed regression for lynx fuji device for open directory (but probably more) where a fixed transfer of 256 was assumed in shared fuji device code, but Lynx Config sends variable length string. transaction_get was failing if the read wasn't the fixed buffer size in length.
1 parent 56e10b0 commit 0f21d24

File tree

11 files changed

+26
-173
lines changed

11 files changed

+26
-173
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[fujinet]
2+
build_platform = BUILD_LYNX
3+
build_bus = comlynx
4+
build_board = fujinet-lynx-devkitc
5+
6+
[env:fujinet-lynx-devkitc]
7+
platform = espressif32@${fujinet.esp32_platform_version}
8+
platform_packages = ${fujinet.esp32_platform_packages}
9+
board = fujinet-v1-8mb
10+
build_type = debug
11+
build_flags =
12+
${env.build_flags}
13+
-D PINMAP_LYNX

lib/bus/comlynx/comlynx.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
#define IDLE_TIME 500 // Idle tolerance in microseconds (roughly three characters at 62500 baud)
1717

18-
//systemBus SYSTEM_BUS.;
19-
2018
static QueueHandle_t reset_evt_queue = NULL;
2119

2220
static void IRAM_ATTR comlynx_reset_isr_handler(void *arg)
@@ -367,46 +365,16 @@ void systemBus::addDevice(virtualDevice *pDevice, fujiDeviceID_t device_id)
367365
}
368366

369367
pDevice->_devnum = device_id;
370-
//_daisyChain[device_id] = pDevice;
371368
_daisyChain.push_front(pDevice);
372-
373-
/*switch (device_id)
374-
{
375-
case FUJI_DEVICEID_PRINTER:
376-
_printerDev = (lynxPrinter *)pDevice;
377-
break;
378-
case FUJI_DEVICEID_FUJINET:
379-
_fujiDev = (lynxFuji *)pDevice;
380-
break;
381-
default:
382-
break;
383-
}*/
384369
}
385370

386-
/*bool systemBus::deviceExists(fujiDeviceID_t device_id)
387-
{
388-
return _daisyChain.find(device_id) != _daisyChain.end();
389-
}*/
390-
391-
/*bool systemBus::deviceEnabled(fujiDeviceID_t device_id)
392-
{
393-
if (deviceExists(device_id))
394-
return _daisyChain[device_id]->device_active;
395-
else
396-
return false;
397-
}*/
398-
399371
void systemBus::remDevice(virtualDevice *pDevice)
400372
{
401373
_daisyChain.remove(pDevice);
402374
}
403375

404376
void systemBus::remDevice(fujiDeviceID_t device_id)
405377
{
406-
/*if (deviceExists(device_id))
407-
{
408-
_daisyChain.erase(device_id);
409-
}*/
410378
}
411379

412380
int systemBus::numDevices()
@@ -446,18 +414,10 @@ void systemBus::reset()
446414

447415
void systemBus::enableDevice(fujiDeviceID_t device_id)
448416
{
449-
/*Debug_printf("Enabling Comlynx Device %d\n", device_id);
450-
451-
if (_daisyChain.find(device_id) != _daisyChain.end())
452-
_daisyChain[device_id]->device_active = true;*/
453417
}
454418

455419
void systemBus::disableDevice(fujiDeviceID_t device_id)
456420
{
457-
/*Debug_printf("Disabling Comlynx Device %d\n", device_id);
458-
459-
if (_daisyChain.find(device_id) != _daisyChain.end())
460-
_daisyChain[device_id]->device_active = false;*/
461421
}
462422

463423
void systemBus::setUDPHost(const char *hostname, int port)
@@ -509,15 +469,13 @@ void systemBus::setUDPHost(const char *hostname, int port)
509469
}
510470
}
511471

512-
513472
void systemBus::setRedeyeMode(bool enable)
514473
{
515474
Debug_printf("setRedeyeMode, %d\n", enable);
516475
_udpDev->redeye_mode = enable;
517476
_udpDev->redeye_logon = true;
518477
}
519478

520-
521479
void systemBus::setRedeyeGameRemap(uint32_t remap)
522480
{
523481
Debug_printf("setRedeyeGameRemap, %d\n", remap);

lib/bus/comlynx/comlynx.h

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,6 @@
1818

1919
#define COMLYNX_BAUDRATE 62500
2020

21-
#define MN_RESET 0x00 // command.control (reset)
22-
#define MN_STATUS 0x01 // command.control (status)
23-
#define MN_ACK 0x02 // command.control (ack)
24-
#define MN_CLR 0x03 // command.control (clr) (aka CTS)
25-
#define MN_RECEIVE 0x04 // command.control (receive)
26-
#define MN_CANCEL 0x05 // command.control (cancel)
27-
#define MN_SEND 0x06 // command.control (send)
28-
#define MN_NACK 0x07 // command.control (nack)
29-
#define MN_READY 0x0D // command.control (ready)
30-
31-
#define NM_STATUS 0x08 // response.control (status)
32-
#define NM_ACK 0x09 // response.control (ack)
33-
#define NM_CANCEL 0x0A // response.control (cancel)
34-
#define NM_SEND 0x0B // response.data (send)
35-
#define NM_NACK 0x0C // response.control (nack)
36-
37-
3821
#define COMLYNX_RESET_DEBOUNCE_PERIOD 100 // in ms
3922

4023
class systemBus;
@@ -137,11 +120,6 @@ class virtualDevice
137120
*/
138121
virtual void comlynx_response_nack();
139122

140-
/**
141-
* @brief acknowledge if device is ready, but not if cmd took too long.
142-
*/
143-
//virtual void comlynx_control_ready();
144-
145123
/**
146124
* @brief Device Number: 0-15
147125
*/
@@ -155,36 +133,11 @@ class virtualDevice
155133
*/
156134
virtual void comlynx_process();
157135

158-
/**
159-
* @brief Do any tasks that can only be done when the bus is quiet
160-
*/
161-
//virtual void comlynx_idle();
162-
163-
/**
164-
* @brief send current status of device
165-
*/
166-
//virtual void comlynx_control_status();
167-
168-
/**
169-
* @brief lynx says clear to send!
170-
*/
171-
//virtual void comlynx_control_clr();
172-
173-
/**
174-
* @brief send status response
175-
*/
176-
//virtual void comlynx_response_status();
177-
178136
/**
179137
* @brief command frame, used by network protocol, ultimately
180138
*/
181139
cmdFrame_t cmdFrame;
182140

183-
/**
184-
* The response sent in comlynx_response_status()
185-
*/
186-
//uint8_t status_response[6] = {0x80,0x00,0x00,0x01,0x00,0x00};
187-
188141
/**
189142
* Response buffer and length
190143
*/
@@ -225,7 +178,6 @@ class virtualDevice
225178
class systemBus
226179
{
227180
private:
228-
//std::map<uint8_t, virtualDevice *> _daisyChain;
229181
std::forward_list<virtualDevice *> _daisyChain;
230182
virtualDevice *_activeDev = nullptr;
231183
lynxFuji *_fujiDev = nullptr;
@@ -253,7 +205,7 @@ class systemBus
253205
/**
254206
* stopwatch
255207
*/
256-
int64_t start_time;
208+
//int64_t start_time;
257209

258210
int numDevices();
259211
void addDevice(virtualDevice *pDevice, fujiDeviceID_t device_id);

lib/device/comlynx/disk.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ success_is_true lynxDisk::transaction_get(void *data, size_t len)
5555
RETURN_SUCCESS_IF(len == to_copy);
5656
}
5757

58-
5958
void lynxDisk::transaction_put(const void *data, size_t len, bool err)
6059
{
6160
uint8_t b;

lib/device/comlynx/disk.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@
55
#include "bus.h"
66
#include "media.h"
77

8-
/*
9-
#define STATUS_OK 0
10-
#define STATUS_BAD_BLOCK 1
11-
#define STATUS_NO_BLOCK 2
12-
#define STATUS_NO_MEDIA 3
13-
#define STATUS_NO_DRIVE 4
14-
*/
158

169
class lynxDisk : public virtualDevice
1710
{
1811
private:
1912
MediaType *_media = nullptr;
20-
TaskHandle_t diskTask;
21-
13+
2214
unsigned long blockNum=INVALID_SECTOR_VALUE;
2315

2416
//void transaction_continue(transState_t expectMoreData) override {};

lib/device/comlynx/lynxFuji.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ success_is_true lynxFuji::transaction_get(void *data, size_t len)
130130
memcpy(data, recvbuf_pos, to_copy);
131131
recvbuf_pos += to_copy;
132132

133-
RETURN_SUCCESS_IF(len == to_copy);
133+
//RETURN_SUCCESS_IF(len == to_copy);
134+
RETURN_SUCCESS_IF(len != 0);
134135
}
135136

136137

lib/device/comlynx/network.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -769,9 +769,6 @@ void lynxNetwork::parse_and_instantiate_protocol(string d)
769769
{
770770
}*/
771771

772-
/*void lynxNetwork::comlynx_set_timer_rate()
773-
{
774-
}*/
775772

776773
void lynxNetwork::process_fs(fujiCommandID_t cmd, unsigned pkt_len)
777774
{

lib/device/comlynx/network.h

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
#ifndef NETWORK_H
22
#define NETWORK_H
33

4-
#include <esp_timer.h>
4+
//#include <esp_timer.h>
55
#include <memory>
66
#include <string>
77

88
#include "bus.h"
9-
109
#include "peoples_url_parser.h"
11-
1210
#include "Protocol.h"
13-
1411
#include "fnjson.h"
15-
1612
#include "ProtocolParser.h"
1713

1814
/**
@@ -49,13 +45,7 @@ class lynxNetwork : public virtualDevice
4945
/**
5046
* The spinlock for the ESP32 hardware timers. Used for interrupt rate limiting.
5147
*/
52-
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
53-
54-
/**
55-
* Toggled by the rate limiting timer to indicate that the PROCEED interrupt should
56-
* be pulsed.
57-
*/
58-
bool interruptProceed = false;
48+
//portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
5949

6050
/**
6151
* Called for LYNX Command 'O' to open a connection to a network protocol, allocate all buffers,
@@ -213,11 +203,6 @@ class lynxNetwork : public virtualDevice
213203
*/
214204
nDevStatus_t err = NDEV_STATUS::SUCCESS;
215205

216-
/**
217-
* ESP timer handle for the Interrupt rate limiting timer
218-
*/
219-
esp_timer_handle_t rateTimerHandle = nullptr;
220-
221206
/**
222207
* Devicespec passed to us, e.g. N:HTTP://WWW.GOOGLE.COM:80/
223208
*/
@@ -254,11 +239,6 @@ class lynxNetwork : public virtualDevice
254239
*/
255240
std::string password;
256241

257-
/**
258-
* Timer Rate for interrupt timer
259-
*/
260-
int timerRate = 100;
261-
262242
/**
263243
* The channel mode for the currently open LYNX device. By default, it is PROTOCOL, which passes
264244
* read/write/status commands to the protocol. Otherwise, it's a special mode, e.g. to pass to
@@ -304,16 +284,6 @@ class lynxNetwork : public virtualDevice
304284
*/
305285
void create_url_parser();
306286

307-
/**
308-
* Start the Interrupt rate limiting timer
309-
*/
310-
void timer_start();
311-
312-
/**
313-
* Stop the Interrupt rate limiting timer
314-
*/
315-
void timer_stop();
316-
317287
/**
318288
* We were passed a COPY arg from DOS 2. This is complex, because we need to parse the comma,
319289
* and figure out one of three states:
@@ -361,11 +331,6 @@ class lynxNetwork : public virtualDevice
361331
*/
362332
void comlynx_set_translation();
363333

364-
/**
365-
* @brief Set timer rate for PROCEED timer in ms
366-
*/
367-
void comlynx_set_timer_rate();
368-
369334
/**
370335
* @brief parse URL and instantiate protocol
371336
* @param db pointer to devicespecbuf 256 chars

lib/device/comlynx/printer.cpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ lynxPrinter::lynxPrinter(FileSystem *filesystem, printer_type print_type)
6161
getPrinterPtr()->setTranslate850(false);
6262
getPrinterPtr()->setEOL(0x0D);
6363

64-
xTaskCreate(printerTask, "ptsk", 4096, this, PRINTER_PRIORITY, &thPrinter);
64+
//xTaskCreate(printerTask, "ptsk", 4096, this, PRINTER_PRIORITY, &thPrinter);
6565
}
6666

6767
lynxPrinter::~lynxPrinter()
6868
{
69-
if (thPrinter != nullptr)
70-
vTaskDelete(thPrinter);
69+
//if (thPrinter != nullptr)
70+
//vTaskDelete(thPrinter);
7171

7272
if (_pptr != nullptr)
7373
{
@@ -90,15 +90,6 @@ lynxPrinter::printer_type lynxPrinter::match_modelname(std::string model_name)
9090
return (printer_type)i;
9191
}
9292

93-
/*
94-
void lynxPrinter::comlynx_control_status()
95-
{
96-
uint8_t c[6] = {0x82, 0x10, 0x00, 0x00, 0x00, 0x10};
97-
98-
comlynx_send_buffer(c, sizeof(c));
99-
}
100-
*/
101-
10293
void lynxPrinter::perform_print()
10394
{
10495
memcpy(_pptr->provideBuffer(),pi.buf,pi.len);
@@ -136,20 +127,7 @@ void lynxPrinter::comlynx_control_ready()
136127

137128
void lynxPrinter::comlynx_process()
138129
{
139-
/*unsigned char c = b >> 4;
140130

141-
switch (c)
142-
{
143-
case MN_STATUS:
144-
comlynx_control_status();
145-
break;
146-
case MN_SEND:
147-
comlynx_control_send();
148-
break;
149-
case MN_READY:
150-
comlynx_control_ready();
151-
break;
152-
}*/
153131
}
154132

155133
void lynxPrinter::shutdown()

0 commit comments

Comments
 (0)