+byte_t rx[0x1000000];
+byte_t* prx = rx;
+
+// static void showBanner(void){
+ // printf("██████╗ ███╗ ███╗ ████╗ ...Iceman fork\n");
+ // printf("██╔══██╗████╗ ████║ ══█║\n");
+ // printf("██████╔╝██╔████╔██║ ████╔╝\n");
+ // printf("██╔═══╝ ██║╚██╔╝██║ ══█║ iceman@icesql.net\n");
+ // printf("██║ ██║ ╚═╝ ██║ ████╔╝ https://github.com/iceman1001/proxmark3\n");
+ // printf("╚═╝ ╚═╝ ╚═╝ ╚═══╝v1.7.0\n");
+// }
+
+
+static void *uart_receiver(void *targ) {
+ struct receiver_arg *arg = (struct receiver_arg*)targ;
+ size_t rxlen;
+ size_t cmd_count;
+
+ while (arg->run) {
+
+ rxlen = sizeof(UsbCommand);
+
+ if (uart_receive(sp, prx, &rxlen)) {
+ prx += rxlen;
+ if (((prx-rx) % sizeof(UsbCommand)) != 0)
+ continue;
+
+ cmd_count = (prx-rx) / sizeof(UsbCommand);
+
+ for (size_t i = 0; i < cmd_count; i++)
+ UsbCommandReceived((UsbCommand*)( rx + ( i * sizeof(UsbCommand))));
+
+ }
+ prx = rx;
+
+ if (txcmd_pending) {
+ bool res = uart_send(sp, (byte_t*) &txcmd, sizeof(UsbCommand));
+ if (!res) {
+ PrintAndLog("Sending bytes to proxmark failed");
+ }
+ txcmd_pending = false;
+ }
+ }
+ pthread_exit(NULL);
+ return NULL;
+}
+
+static void *main_loop(void *targ) {
+ struct main_loop_arg *arg = (struct main_loop_arg*)targ;
+ struct receiver_arg rarg;
+ char *cmd = NULL;
+ pthread_t reader_thread;
+
+ if (arg->usb_present == 1) {
+ rarg.run = 1;
+ pthread_create(&reader_thread, NULL, &uart_receiver, &rarg);
+ // cache Version information now:
+ CmdVersion(NULL);
+ }
+
+ FILE *script_file = NULL;
+ char script_cmd_buf[256] = {0x00}; // iceman, needs lua script the same file_path_buffer as the rest
+
+ if (arg->script_cmds_file) {
+ script_file = fopen(arg->script_cmds_file, "r");
+
+ if (script_file)
+ printf("using 'scripting' commands file %s\n", arg->script_cmds_file);
+ }
+
+ read_history(".history");
+
+ while(1) {
+
+ // If there is a script file
+ if (script_file) {
+
+ if (!fgets(script_cmd_buf, sizeof(script_cmd_buf), script_file)) {
+ fclose(script_file);
+ script_file = NULL;
+ } else {
+ char *nl;
+ nl = strrchr(script_cmd_buf, '\r');
+ if (nl)
+ *nl = '\0';
+
+ nl = strrchr(script_cmd_buf, '\n');
+
+ if (nl)
+ *nl = '\0';
+
+ int newlen = strlen(script_cmd_buf);
+ if ((cmd = (char*) malloc( newlen + 1)) != NULL) {
+ memset(cmd, 0x00, newlen);
+ strcpy(cmd, script_cmd_buf);
+ printf("%s\n", cmd);
+ }
+ }
+ } else {
+ cmd = readline(PROXPROMPT);
+ }
+
+ // this one should pick up all non-null cmd...
+ // why is there a
+ if (cmd) {
+ if (strlen(cmd) > 0) {
+ while(cmd[strlen(cmd) - 1] == ' ')
+ cmd[strlen(cmd) - 1] = 0x00;
+ }
+
+ if (cmd[0] != 0x00) {
+ int ret = CommandReceived(cmd);
+ add_history(cmd);
+
+ // exit or quit
+ if (ret == 99)
+ break;
+ }
+ free(cmd);
+ cmd = 0;
+ } else {
+ printf("\n");
+ break;
+ }
+ }
+
+ if (script_file) {
+ fclose(script_file);
+ }
+
+ write_history(".history");
+
+ free(cmd);
+ cmd = 0;
+
+ if (arg->usb_present == 1) {
+ rarg.run = 0;
+ pthread_join(reader_thread, NULL);
+ }
+
+ ExitGraphics();
+ pthread_exit(NULL);
+ return NULL;
+}
+
+static void dumpAllHelp(int markdown)