1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-12-21 12:29:51 +00:00

add checkpoint/restore for socket filer

This commit is contained in:
Stephen Crane 2019-03-30 11:55:34 +00:00
parent d7c82c67a1
commit 421989bfc5
6 changed files with 47 additions and 27 deletions

23
filer.h
View File

@ -13,27 +13,4 @@ public:
virtual void stop() =0;
};
// split into sd_filer and fs_filer
// implement write to new file (like checkpoint)
class flash_filer: public filer {
public:
flash_filer(const char *programs): _programs(programs) {}
const char *advance();
const char *rewind();
const char *checkpoint();
void restore(const char *);
bool start();
void stop();
uint8_t read() { return _buf[_pos++]; }
bool more();
private:
const char *_programs;
unsigned _pos, _len;
uint8_t _buf[128];
};
#endif

View File

@ -14,6 +14,7 @@
#include "serialio.h"
#include "filer.h"
#include "flash_filer.h"
#if defined(DISK)
static File file, dir;

27
flash_filer.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef __FLASH_FILER_H__
#define __FLASH_FILER_H__
// split into sd_filer and fs_filer
// implement write to new file (like checkpoint)
class flash_filer: public filer {
public:
flash_filer(const char *programs): _programs(programs) {}
const char *advance();
const char *rewind();
const char *checkpoint();
void restore(const char *);
bool start();
void stop();
uint8_t read() { return _buf[_pos++]; }
bool more();
private:
const char *_programs;
unsigned _pos, _len;
uint8_t _buf[128];
};
#endif

View File

@ -11,6 +11,7 @@
#include "keyboard.h"
#include "serialio.h"
#include "filer.h"
#include "flash_filer.h"
#include "serial_filer.h"
#include "socket_filer.h"
#include "timed.h"

View File

@ -20,6 +20,12 @@ static bool connected() {
return client.connected();
}
const char *socket_filer::advance() {
if (connected())
return "connected";
return 0;
}
bool socket_filer::start() {
#if defined(WIFI_SSID)
@ -53,12 +59,20 @@ bool socket_filer::more() {
#if !defined(NO_CHECKPOINT)
const char *socket_filer::checkpoint() {
// FIXME
return 0;
if (connected()) {
hardware_checkpoint(client);
client.flush();
client.stop();
return "checkpointed";
}
return "not connected";
}
void socket_filer::restore(const char *) {
// FIXME
if (connected()) {
hardware_restore(client);
client.stop();
}
}
#endif

View File

@ -5,7 +5,7 @@ class socket_filer: public filer {
public:
socket_filer(const char *hostname): _hostname(hostname) {}
const char *advance() { return 0; }
const char *advance();
const char *rewind() { return advance(); }
const char *checkpoint();