USB comms: part 2 towards @micolous PR#463 (#595)

* change variable 'offline' from global to static
* change variable 'FlushAfterWrite' from global to static
* remove unused global variable 'current_command'
* WaitForResponseTimeoutW(CMD_UNKNOWN, ...) waits for any command
* #include "printf.h" or <stdio.h> in iso15693tools.c to define sprintf()
* and some minor changes/comments
This commit is contained in:
pwpiwi 2018-04-24 08:27:29 +02:00 committed by GitHub
commit 61aaee35cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 61 additions and 35 deletions

View file

@ -41,14 +41,17 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
pthread_t reader_thread;
bool execCommand = (script_cmd != NULL);
bool stdinOnPipe = !isatty(STDIN_FILENO);
memset(&conn, 0, sizeof(receiver_arg));
if (usb_present) {
conn.run = true;
SetOffline(false);
pthread_create(&reader_thread, NULL, &uart_receiver, &conn);
// cache Version information now:
CmdVersion(NULL);
} else {
SetOffline(true);
}
// file with script
@ -64,7 +67,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
read_history(".history");
while (1) {
while (1) {
// If there is a script file
if (script_file)
{
@ -235,7 +238,7 @@ int main(int argc, char* argv[]) {
if(strcmp(argv[i],"-f") == 0 || strcmp(argv[i],"-flush") == 0){
printf("Output will be flushed after every print.\n");
flushAfterWrite = 1;
SetFlushAfterWrite(true);
}
if(strcmp(argv[i],"-w") == 0 || strcmp(argv[i],"-wait") == 0){
@ -311,14 +314,11 @@ int main(int argc, char* argv[]) {
if (sp == INVALID_SERIAL_PORT) {
printf("ERROR: invalid serial port\n");
usb_present = false;
offline = 1;
} else if (sp == CLAIMED_SERIAL_PORT) {
printf("ERROR: serial port is claimed by another process\n");
usb_present = false;
offline = 1;
} else {
usb_present = true;
offline = 0;
}
#ifdef HAVE_GUI