1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-25 17:18:06 +11:00
collapseos/tools/common.c
Virgil Dupras 7907687abf tools/uploadb: make it much much faster
By uploading a BASIC loop and then run it, we can reduce the serial
communication to pure content which greatly reduces the overhead and make
the process much much faster.
2019-12-11 09:27:05 -05:00

27 lines
559 B
C

#include <stdlib.h>
#include <unistd.h>
void sendcmd(int fd, char *cmd)
{
char junk[2];
while (*cmd) {
write(fd, cmd, 1);
read(fd, &junk, 1);
cmd++;
// The other side is sometimes much slower than us and if we don't let
// it breathe, it can choke.
usleep(1000);
}
write(fd, "\n", 1);
read(fd, &junk, 2); // sends back \r\n
usleep(1000);
}
// Send a cmd and also read the "> " prompt
void sendcmdp(int fd, char *cmd)
{
char junk[2];
sendcmd(fd, cmd);
read(fd, &junk, 2);
}