Browse Source

tools: add blkup

not actually tested yet...
pull/102/head
Virgil Dupras 4 years ago
parent
commit
7344186c62
4 changed files with 14 additions and 5 deletions
  1. +4
    -2
      tools/Makefile
  2. +8
    -2
      tools/common.c
  3. +1
    -0
      tools/common.h
  4. +1
    -1
      tools/upload.c

+ 4
- 2
tools/Makefile 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 $@



+ 8
- 2
tools/common.c 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


+ 1
- 0
tools/common.h 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);


+ 1
- 1
tools/upload.c 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);


Loading…
Cancel
Save