Skip to content

Commit

Permalink
[PC] merge lib/config
Browse files Browse the repository at this point in the history
  • Loading branch information
a8jan committed Nov 9, 2023
1 parent 4521132 commit 4bf5efa
Show file tree
Hide file tree
Showing 17 changed files with 522 additions and 69 deletions.
36 changes: 18 additions & 18 deletions fujinet_pc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ set(INCLUDE_DIRS include

set(SOURCES
# set(SOURCES src/main.cpp
# lib/config/fnConfig.h lib/config/fnConfig.cpp
# lib/config/fnc_bt.cpp
# lib/config/fnc_cassette.cpp
# lib/config/fnc_cpm.cpp
# lib/config/fnc_enable.cpp
# lib/config/fnc_general.cpp
# lib/config/fnc_hosts.cpp
# lib/config/fnc_load.cpp
# lib/config/fnc_modem.cpp
# lib/config/fnc_mounts.cpp
# lib/config/fnc_network.cpp
# lib/config/fnc_phonebook.cpp
# lib/config/fnc_printer.cpp
# lib/config/fnc_save.cpp
# lib/config/fnc_serial.cpp
# lib/config/fnc_util.cpp
# lib/config/fnc_wifi.cpp
lib/config/fnConfig.h lib/config/fnConfig.cpp
lib/config/fnc_bt.cpp
lib/config/fnc_cassette.cpp
lib/config/fnc_cpm.cpp
lib/config/fnc_enable.cpp
lib/config/fnc_general.cpp
lib/config/fnc_hosts.cpp
lib/config/fnc_load.cpp
lib/config/fnc_modem.cpp
lib/config/fnc_mounts.cpp
lib/config/fnc_network.cpp
lib/config/fnc_phonebook.cpp
lib/config/fnc_printer.cpp
lib/config/fnc_save.cpp
lib/config/fnc_serial.cpp
lib/config/fnc_util.cpp
lib/config/fnc_wifi.cpp
include/debug.h
lib/utils/utils.h lib/utils/utils.cpp
lib/utils/cbuf.h lib/utils/cbuf.cpp
Expand Down Expand Up @@ -208,7 +208,7 @@ set(SOURCES
# lib/base64/base64.h lib/base64/base64.c
# lib/encrypt/crypt.h lib/encrypt/crypt.cpp
# lib/compat/compat_inet.c
# lib/compat/compat_gettimeofday.c
lib/compat/compat_gettimeofday.h lib/compat/compat_gettimeofday.c
)

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
Expand Down
33 changes: 30 additions & 3 deletions lib/FileSystem/fnFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,28 @@
#include <time.h>

#include <stdio.h>
#include <stdint.h>


#ifndef ESP_PLATFORM
#include "compat_dirent.h"
#include "fnFile.h"
#endif

#ifndef FILE_READ
#define FILE_READ "r"
#define FILE_WRITE "w"
#define FILE_APPEND "a"
#define FILE_READ "rb"
#define FILE_WRITE "wb"
#define FILE_APPEND "ab"
#define FILE_READ_TEXT "rt"
#define FILE_WRITE_TEXT "wt"
#define FILE_APPEND_TEXT "at"
#endif

#ifdef ESP_PLATFORM
#define MAX_PATHLEN 256
#else
#define MAX_PATHLEN 1024
#endif

#define FNFS_INVALID_DIRPOS 0xFFFF

Expand All @@ -22,6 +35,10 @@ enum fsType
FSTYPE_LITTLEFS,
FSTYPE_SDFAT,
FSTYPE_TNFS,
#ifndef ESP_PLATFORM
FSTYPE_SMB,
FSTYPE_FTP,
#endif
FSTYPE_COUNT
};

Expand All @@ -40,7 +57,11 @@ typedef struct fsdir_entry fsdir_entry_t;
class FileSystem
{
protected:
#ifdef ESP_PLATFORM
char _basepath[20] = { '\0' };
#else
char _basepath[MAX_PATHLEN] = { '\0' };
#endif
bool _started = false;
fsdir_entry _direntry;

Expand All @@ -61,13 +82,19 @@ class FileSystem
static const char *type_to_string(fsType type);

static long filesize(FILE *);
#ifndef ESP_PLATFORM
static long filesize(FileHandler *);
#endif
static long filesize(const char *filepath);

// Different FS implemenations may require different startup parameters,
// so each should define its own version of start()
//virtual bool start()=0;

virtual FILE * file_open(const char* path, const char* mode = FILE_READ) = 0;
#ifndef ESP_PLATFORM
virtual FileHandler * filehandler_open(const char* path, const char* mode = FILE_READ) = 0;
#endif

virtual bool exists(const char* path) = 0;

Expand Down
15 changes: 14 additions & 1 deletion lib/FileSystem/fnFsSD.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef _FN_FSSD_
#define _FN_FSSD_

#include <esp_vfs_fat.h>
#ifdef ESP_PLATFORM
#include "esp_vfs_fat.h"
#endif

#include <stdio.h>

Expand All @@ -10,16 +12,27 @@
class FileSystemSDFAT : public FileSystem
{
private:
#ifdef ESP_PLATFORM
FF_DIR _dir;
#else
DIR * _dir;
#endif
uint64_t _card_capacity = 0;
public:
#ifdef ESP_PLATFORM
bool start();
#else
bool start(const char *sd_path = nullptr);
#endif
virtual bool is_global() override { return true; };

fsType type() override { return FSTYPE_SDFAT; };
const char * typestring() override { return type_to_string(FSTYPE_SDFAT); };

FILE * file_open(const char* path, const char* mode = FILE_READ) override;
#ifndef ESP_PLATFORM
FileHandler * filehandler_open(const char* path, const char* mode = FILE_READ) override;
#endif

bool exists(const char* path) override;

Expand Down
25 changes: 21 additions & 4 deletions lib/bus/sio/sio.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#ifndef SIO_H
#define SIO_H

#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>

#include <forward_list>

#ifdef ESP_PLATFORM
#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>
#else
#include "sio/siocom/fnSioCom.h"
#endif

#define DELAY_T4 850
#define DELAY_T5 250
Expand Down Expand Up @@ -47,6 +50,7 @@ FN_HISPEED_INDEX=40 // 18,806 (18,806) baud
#define SIO_STANDARD_BAUDRATE 19200

#define SIO_HISPEED_LOWEST_INDEX 0x0A // Lowest HSIO index we'll accept
#define SIO_HISPEED_x2_INDEX 0x10 // this index is accepted too (by FujiNet-PC)

#define COMMAND_FRAME_SPEED_CHANGE_THRESHOLD 2
#define SERIAL_TIMEOUT 300
Expand Down Expand Up @@ -146,7 +150,9 @@ class virtualDevice
* Atari that we are now processing the command.
*/
void sio_ack();

#ifndef ESP_PLATFORM
void sio_late_ack(); // for NetSIO, ACK is delayed until we now how much data will be read from Atari
#endif
/**
* @brief Send a non-acknowledgement (NAK) to the Atari 'N'
* This should be used if the command received by the SIO device is invalid, in the first place. It is not
Expand Down Expand Up @@ -263,6 +269,10 @@ class systemBus

bool useUltraHigh = false; // Use fujinet derived clock.

#ifndef ESP_PLATFORM
bool _command_processed = false;
#endif

void _sio_process_cmd();
void _sio_process_queue();

Expand Down Expand Up @@ -293,14 +303,21 @@ class systemBus
bool shuttingDown = false; // TRUE if we are in shutdown process
bool getShuttingDown() { return shuttingDown; };

#ifndef ESP_PLATFORM
void set_command_processed(bool processed);
void sio_empty_ack(); // for NetSIO, notify hub we are not interested to handle the command
#endif

sioCassette *getCassette() { return _cassetteDev; }
sioPrinter *getPrinter() { return _printerdev; }
sioCPM *getCPM() { return _cpmDev; }

// I wish this codebase would make up its mind to use camel or snake casing.
modem *get_modem() { return _modemDev; }

#ifdef ESP_PLATFORM
QueueHandle_t qSioMessages = nullptr;
#endif
};

extern systemBus SIO;
Expand Down
2 changes: 1 addition & 1 deletion lib/config/fnConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "fnConfig.h"
#include <cstring>
#include "compat_string.h"

fnConfig Config;

Expand Down
Loading

0 comments on commit 4bf5efa

Please sign in to comment.