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:
parent
d7c82c67a1
commit
421989bfc5
23
filer.h
23
filer.h
@ -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
|
||||
|
@ -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
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 "serialio.h"
|
||||
#include "filer.h"
|
||||
#include "flash_filer.h"
|
||||
#include "serial_filer.h"
|
||||
#include "socket_filer.h"
|
||||
#include "timed.h"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user