mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-24 14:38:05 +11:00
tools: add blkup
not actually tested yet...
This commit is contained in:
parent
f023f9bcb4
commit
7344186c62
@ -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 $@
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user