X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/5acd195d0fe7dffc36daaada39d0d34ae87b8e1b..refs/pull/420/head:/client/proxmark3.c

diff --git a/client/proxmark3.c b/client/proxmark3.c
index 460aea29..956eb6a8 100644
--- a/client/proxmark3.c
+++ b/client/proxmark3.c
@@ -57,26 +57,22 @@ struct receiver_arg {
 	int run;
 };
 
-byte_t rx[0x1000000];
+byte_t rx[sizeof(UsbCommand)];
 byte_t* prx = rx;
 
 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)) {
+		rxlen = 0;
+		if (uart_receive(sp, prx, sizeof(UsbCommand) - (prx-rx), &rxlen)) {
 			prx += rxlen;
-			if (((prx-rx) % sizeof(UsbCommand)) != 0) {
+			if (prx-rx < sizeof(UsbCommand)) {
 				continue;
 			}
-			cmd_count = (prx-rx) / sizeof(UsbCommand);
-
-			for (size_t i = 0; i < cmd_count; i++) {
-				UsbCommandReceived((UsbCommand*)(rx+(i*sizeof(UsbCommand))));
-			}
+			
+			UsbCommandReceived((UsbCommand*)rx);
 		}
 		prx = rx;
 
@@ -278,8 +274,22 @@ int main(int argc, char* argv[]) {
 	pthread_mutex_init(&print_lock, NULL);
 
 #ifdef HAVE_GUI
+#ifdef _WIN32
 	InitGraphics(argc, argv, script_cmds_file, usb_present);
 	MainGraphics();
+#else
+	char* display = getenv("DISPLAY");
+
+	if (display && strlen(display) > 1)
+	{
+		InitGraphics(argc, argv, script_cmds_file, usb_present);
+		MainGraphics();
+	}
+	else
+	{
+		main_loop(script_cmds_file, usb_present);
+	}
+#endif
 #else
 	main_loop(script_cmds_file, usb_present);
 #endif