Skip to content

Commit 9754c72

Browse files
authored
Get rs232 firmware compiling for ESP32 again. (#1064)
1 parent 898b0c9 commit 9754c72

File tree

14 files changed

+31
-53
lines changed

14 files changed

+31
-53
lines changed

include/fujiCommandID.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ enum fujiCommandID_t {
110110
FUJICMD_PERCOM_READ = 0x4E, // N
111111
FUJICMD_UNLISTEN = 0x4D, // M
112112
FUJICMD_LISTEN = 0x4C, // L
113+
FUJICMD_CPM_INIT = 0x47, // G
113114
FUJICMD_GET_ERROR = 0x45, // E
114115
FUJICMD_SET_DESTINATION = 0x44, // D
115116
FUJICMD_SET_DUMP = 0x44, // D

lib/bus/mac/mac_ll.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void IRAM_ATTR encode_rmt_bitstream(const void* src, rmt_item32_t* dest, size_t
111111
*item_num = wanted_num;
112112
}
113113

114+
#ifdef NOT_IWM_LL_SUBCLASSS
114115
/*
115116
* Initialize the RMT Tx channel
116117
*/

lib/bus/rs232/FujiBusPacket.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "FujiBusPacket.h"
22

33
#include "../../include/debug.h"
4+
#include "utils.h"
45

56
typedef struct {
67
uint8_t device; /* Destination Device */
@@ -17,14 +18,6 @@ typedef struct {
1718
static uint8_t fieldSizeTable[] = {0, 1, 1, 1, 1, 2, 2, 4};
1819
static uint8_t numFieldsTable[] = {0, 1, 2, 3, 4, 1, 2, 1};
1920

20-
FujiBusPacket::FujiBusPacket(const std::string &slipEncoded)
21-
{
22-
if (!parse(slipEncoded))
23-
throw std::invalid_argument("Invalid FujiBusPacket data");
24-
25-
return;
26-
}
27-
2821
std::string FujiBusPacket::decodeSLIP(const std::string &input)
2922
{
3023
unsigned int idx;
@@ -203,10 +196,8 @@ std::string FujiBusPacket::serialize()
203196

204197
std::unique_ptr<FujiBusPacket> FujiBusPacket::fromSerialized(const std::string &input)
205198
{
206-
try {
207-
return std::make_unique<FujiBusPacket>(input);
208-
}
209-
catch (const std::invalid_argument&) {
199+
auto packet = std::make_unique<FujiBusPacket>();
200+
if (!packet->parse(input))
210201
return nullptr;
211-
}
202+
return packet;
212203
}

lib/bus/rs232/FujiBusPacket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FujiBusPacket
3131
uint8_t calcChecksum(const std::string &buf);
3232

3333
public:
34-
FujiBusPacket(const std::string &slipEncoded);
34+
FujiBusPacket() = default;
3535
FujiBusPacket(fujiDeviceID_t dev, fujiCommandID_t cmd, const std::string &dbuf) :
3636
_device(dev), _command(cmd), _data(dbuf) {}
3737

lib/bus/rs232/rs232.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ void systemBus::setUltraHigh(bool _enable, int _ultraHighBaud)
491491
void systemBus::sendReplyPacket(fujiDeviceID_t source, bool ack, void *data, size_t length)
492492
{
493493
FujiBusPacket packet(source, ack ? FUJICMD_ACK : FUJICMD_NAK,
494-
ack ? std::string(static_cast<const char*>(data), length) : nullptr);
494+
ack ? std::string(static_cast<const char*>(data), length) : "");
495495
std::string encoded = packet.serialize();
496496
_port->write(encoded.data(), encoded.size());
497497
return;

lib/console/Commands/VFSCommands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ int mount(int argc, char **argv)
354354
int did = atoi(argv[1]);
355355
fprintf(stdout, "Mounted %d -> %s\r\n", did, argv[2]);
356356

357-
theFuji->mount_all();
357+
theFuji->fujicmd_mount_all_success();
358358

359359
return EXIT_SUCCESS;
360360
}

lib/device/fujiDevice.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
#include "compat_string.h"
3333

3434
#include "fuji_endian.h"
35+
#ifndef ESP_PLATFORM // why ESP does not like it? it throws a linker error undefined reference to 'basename'
3536
#include <libgen.h>
37+
#endif /* ESP_PLATFORM */
3638

3739
#ifdef UNUSED
3840
#define ADDITIONAL_DETAILS_BYTES 10

lib/device/rs232/apetime.cpp

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#include "../../include/debug.h"
1010

11-
char * ape_timezone = NULL;
12-
1311
void rs232ApeTime::_rs232_get_time(bool use_timezone)
1412
{
1513
char old_tz[64];
@@ -24,16 +22,16 @@ void rs232ApeTime::_rs232_get_time(bool use_timezone)
2422

2523
time_t tt = time(nullptr);
2624

27-
if (ape_timezone != NULL && use_timezone) {
25+
if (ape_timezone.size() && use_timezone) {
2826
Debug_printf("Using time zone %s\n", ape_timezone);
2927
strncpy(old_tz, getenv("TZ"), sizeof(old_tz));
30-
setenv("TZ", ape_timezone, 1);
28+
setenv("TZ", ape_timezone.c_str(), 1);
3129
tzset();
3230
}
3331

3432
struct tm * now = localtime(&tt);
3533

36-
if (ape_timezone != NULL && use_timezone) {
34+
if (ape_timezone.size() && use_timezone) {
3735
setenv("TZ", old_tz, 1);
3836
tzset();
3937
}
@@ -53,35 +51,16 @@ void rs232ApeTime::_rs232_get_time(bool use_timezone)
5351
bus_to_computer(rs232_reply, sizeof(rs232_reply), false);
5452
}
5553

56-
void rs232ApeTime::_rs232_set_tz()
54+
void rs232ApeTime::_rs232_set_tz(std::string newTZ)
5755
{
58-
int bufsz;
59-
60-
Debug_println("APETIME set TZ request");
61-
62-
if (ape_timezone != NULL) {
63-
free(ape_timezone);
56+
if (newTZ.size())
57+
{
58+
ape_timezone = newTZ;
59+
Debug_printf("TZ set to <%s>\n", ape_timezone.c_str());
6460
}
65-
66-
#ifdef OBSOLETE
67-
bufsz = rs232_get_aux16_lo();
68-
#endif /* OBSOLETE */
69-
if (bufsz > 0) {
70-
ape_timezone = (char *) malloc((bufsz + 1) * sizeof(char));
71-
72-
uint8_t ck = bus_to_peripheral((uint8_t *) ape_timezone, bufsz);
73-
if (rs232_checksum((uint8_t *) ape_timezone, bufsz) != ck) {
74-
rs232_error();
75-
} else {
76-
ape_timezone[bufsz] = '\0';
77-
78-
rs232_complete();
79-
80-
Debug_printf("TZ set to <%s>\n", ape_timezone);
81-
}
82-
} else {
61+
else
8362
Debug_printf("TZ unset\n");
84-
}
63+
return;
8564
}
8665

8766
void rs232ApeTime::rs232_process(FujiBusPacket &packet)
@@ -94,7 +73,7 @@ void rs232ApeTime::rs232_process(FujiBusPacket &packet)
9473
break;
9574
case FUJICMD_SETTZ:
9675
rs232_ack();
97-
_rs232_set_tz();
76+
_rs232_set_tz(packet.data().value_or(""));
9877
break;
9978
case FUJICMD_GETTZTIME:
10079
rs232_ack();

lib/device/rs232/apetime.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
class rs232ApeTime : public virtualDevice
77
{
88
private:
9+
std::string ape_timezone;
10+
911
void _rs232_get_time(bool use_timezone);
10-
void _rs232_set_tz();
12+
void _rs232_set_tz(std::string newTZ);
1113

1214
public:
1315
void rs232_process(FujiBusPacket &packet) override;

lib/device/rs232/rs232cpm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void rs232CPM::rs232_process(FujiBusPacket &packet)
7474
{
7575
switch (packet.command())
7676
{
77-
case 'G':
77+
case FUJICMD_CPM_INIT:
7878
rs232_ack();
7979
fnSystem.delay(10);
8080
rs232_complete();

0 commit comments

Comments
 (0)