simualtor I/O refactoring - better names and removing duplication

This commit is contained in:
rusefi 2019-02-03 20:37:47 -05:00
parent a2e285835f
commit 9fe4b3896f
4 changed files with 13 additions and 12 deletions

View File

@ -31,7 +31,7 @@ void printToConsole(char *p) {
cputs(p);
}
SerialAdapter_t serialAdapterInstance;
BaseChannel serialAdapterInstance;
/*
* Console print server done using synchronous messages. This makes the access

View File

@ -68,8 +68,16 @@ static msg_t wt_get(void *ip) {
return CONSOLE_PORT->vmt->get(CONSOLE_PORT);
}
static const struct BaseChannelVMT vmt = { wt_writes, wt_reads, wt_put, wt_get, wt_putt, wt_gett, wt_writet, wt_readt };
/**
* These implementation print same content on console screen and send data over the underlying CONSOLE_PORT
* this is useful to see what's going on.
* See #wt_get() as a typical implementation
*/
static const struct BaseChannelVMT vmt = {
wt_writes, wt_reads, wt_put, wt_get,
wt_putt, wt_gett, wt_writet, wt_readt,
};
void initTestStream(SerialAdapter_t *ts) {
void initTestStream(BaseChannel *ts) {
ts->vmt = &vmt;
}

View File

@ -12,7 +12,7 @@ extern "C"
{
#endif /* __cplusplus */
void initTestStream(SerialAdapter_t *ts);
void initTestStream(BaseChannel *ts);
#ifdef __cplusplus
}

View File

@ -55,14 +55,7 @@
// project-wide default thread stack size
#define UTILITY_THREAD_STACK_SIZE 1384
/**
*
*/
typedef struct {
const struct BaseChannelVMT *vmt;
} SerialAdapter_t;
extern SerialAdapter_t serialAdapterInstance;
extern BaseChannel serialAdapterInstance;
#ifdef __cplusplus
extern "C"