mirror of
https://github.com/jscrane/r65emu.git
synced 2024-06-10 06:29:30 +00:00
add checkpoint/restore for socket filer
This commit is contained in:
parent
d7c82c67a1
commit
421989bfc5
23
filer.h
23
filer.h
|
@ -13,27 +13,4 @@ public:
|
||||||
virtual void stop() =0;
|
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
|
#endif
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "serialio.h"
|
#include "serialio.h"
|
||||||
#include "filer.h"
|
#include "filer.h"
|
||||||
|
#include "flash_filer.h"
|
||||||
|
|
||||||
#if defined(DISK)
|
#if defined(DISK)
|
||||||
static File file, dir;
|
static File file, dir;
|
27
flash_filer.h
Normal file
27
flash_filer.h
Normal 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
|
1
r65emu.h
1
r65emu.h
|
@ -11,6 +11,7 @@
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "serialio.h"
|
#include "serialio.h"
|
||||||
#include "filer.h"
|
#include "filer.h"
|
||||||
|
#include "flash_filer.h"
|
||||||
#include "serial_filer.h"
|
#include "serial_filer.h"
|
||||||
#include "socket_filer.h"
|
#include "socket_filer.h"
|
||||||
#include "timed.h"
|
#include "timed.h"
|
||||||
|
|
|
@ -20,6 +20,12 @@ static bool connected() {
|
||||||
return client.connected();
|
return client.connected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *socket_filer::advance() {
|
||||||
|
if (connected())
|
||||||
|
return "connected";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool socket_filer::start() {
|
bool socket_filer::start() {
|
||||||
|
|
||||||
#if defined(WIFI_SSID)
|
#if defined(WIFI_SSID)
|
||||||
|
@ -53,12 +59,20 @@ bool socket_filer::more() {
|
||||||
|
|
||||||
#if !defined(NO_CHECKPOINT)
|
#if !defined(NO_CHECKPOINT)
|
||||||
const char *socket_filer::checkpoint() {
|
const char *socket_filer::checkpoint() {
|
||||||
// FIXME
|
if (connected()) {
|
||||||
return 0;
|
hardware_checkpoint(client);
|
||||||
|
client.flush();
|
||||||
|
client.stop();
|
||||||
|
return "checkpointed";
|
||||||
|
}
|
||||||
|
return "not connected";
|
||||||
}
|
}
|
||||||
|
|
||||||
void socket_filer::restore(const char *) {
|
void socket_filer::restore(const char *) {
|
||||||
// FIXME
|
if (connected()) {
|
||||||
|
hardware_restore(client);
|
||||||
|
client.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class socket_filer: public filer {
|
||||||
public:
|
public:
|
||||||
socket_filer(const char *hostname): _hostname(hostname) {}
|
socket_filer(const char *hostname): _hostname(hostname) {}
|
||||||
|
|
||||||
const char *advance() { return 0; }
|
const char *advance();
|
||||||
const char *rewind() { return advance(); }
|
const char *rewind() { return advance(); }
|
||||||
|
|
||||||
const char *checkpoint();
|
const char *checkpoint();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user