1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 16:18:05 +11:00

tools: add blkup

not actually tested yet...
This commit is contained in:
Virgil Dupras 2020-05-01 14:39:13 -04:00
parent f023f9bcb4
commit 7344186c62
4 changed files with 14 additions and 5 deletions

View File

@ -8,9 +8,10 @@ BIN2C_TGT = bin2c
EXEC_TGT = exec
BLKPACK_TGT = blkpack
BLKUNPACK_TGT = blkunpack
BLKUP_TGT = blkup
TARGETS = $(MEMDUMP_TGT) $(BLKDUMP_TGT) $(UPLOAD_TGT) $(FONTCOMPILE_TGT) \
$(TTYSAFE_TGT) $(PINGPONG_TGT) \
$(BIN2C_TGT) $(EXEC_TGT) $(BLKPACK_TGT) $(BLKUNPACK_TGT)
$(TTYSAFE_TGT) $(PINGPONG_TGT) $(BIN2C_TGT) $(EXEC_TGT) $(BLKPACK_TGT) \
$(BLKUNPACK_TGT) $(BLKUP_TGT)
OBJS = common.o
all: $(TARGETS)
@ -29,6 +30,7 @@ $(BIN2C_TGT): $(BIN2C_TGT).c
$(EXEC_TGT): $(EXEC_TGT).c
$(BLKPACK_TGT): $(BLKPACK_TGT).c
$(BLKUNPACK_TGT): $(BLKUNPACK_TGT).c
$(BLKUP_TGT): $(BLKUP_TGT).c
$(TARGETS): $(OBJS)
$(CC) $(CFLAGS) $@.c $(OBJS) -o $@

View File

@ -16,6 +16,12 @@ void mread(int fd, char *s, int count)
}
}
void readprompt(int fd)
{
char junk[3];
mread(fd, junk, 3); // " ok" prompt
}
void sendcmd(int fd, char *cmd)
{
char junk[2];
@ -32,12 +38,12 @@ void sendcmd(int fd, char *cmd)
usleep(1000);
}
// Send a cmd and also read the "> " prompt
// Send a cmd and also read the " ok" prompt
void sendcmdp(int fd, char *cmd)
{
char junk[2];
sendcmd(fd, cmd);
mread(fd, junk, 2);
readprompt(fd);
}
// from https://stackoverflow.com/a/6947758

View File

@ -1,6 +1,7 @@
void sendcmd(int fd, char *cmd);
void sendcmdp(int fd, char *cmd);
void mread(int fd, char *s, int count);
void readprompt(int fd);
int set_interface_attribs(int fd, int speed, int parity);
void set_blocking(int fd, int should_block);

View File

@ -67,7 +67,7 @@ int main(int argc, char **argv)
}
usleep(1000); // let it breathe
}
mread(fd, s, 2); // "> " prompt
readprompt(fd);
sendcmdp(fd, "FORGET _");
printf("Done!\n");
fclose(fp);