diff options
| author | Pavel Vymetálek <pavel@vym.cz> | 2021-01-17 14:49:15 +0100 | 
|---|---|---|
| committer | Pavel Vymetálek <pavel@vym.cz> | 2021-01-17 14:49:15 +0100 | 
| commit | cc0b5a25a21417d5adb36a9d565a061fbb7f1ae4 (patch) | |
| tree | d272a1971980997bb465f28a777322cb7449f3ad | |
| parent | 39de4ec2d4e87043e2ec5a4fd58dda78ebb2fa4e (diff) | |
| download | sercp-pc-cc0b5a25a21417d5adb36a9d565a061fbb7f1ae4.tar.gz | |
Use gnu99 instead of gnu11, add O_NDELAY to serial port initialization
| -rw-r--r-- | CHANGELOG | 1 | ||||
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | sercp.c | 17 | ||||
| -rw-r--r-- | sercp.rc | 8 | 
4 files changed, 21 insertions, 13 deletions
| @@ -1,3 +1,4 @@ +2020-05-01	v0.3.5 use gnu99 instead of gnu11, add O_NDELAY to serial port initialization  2020-04-08	v0.3.4 removed hw flow control for mac and bsd  2020-04-06	v0.3.3 fixed progressbar for files smaller than 256 bytes  2020-04-05	v0.3.2 changes for __APPLE__ and BSD - still not work on aplle :( @@ -9,7 +9,7 @@ all:	$(PROJECT)  windows: $(PROJECT).w32 $(PROJECT).w64  sercp:	$(PROJECT).c -	$(CC) $(PROJECT).c -o $(PROJECT) -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -O2 -Wformat +	$(CC) $(PROJECT).c -o $(PROJECT) -Wall -pedantic -MP -MD -std=gnu99 -Werror=format-security -O2 -Wformat  install: $(PROJECT)  	install -d $(DESTDIR)$(PREFIX)/bin/ @@ -18,17 +18,17 @@ install: $(PROJECT)  sercp.w64: $(PROJECT).c  	rm -f $(PROJECT).res  	$(WINCC64_PREFIX)-windres -i $(PROJECT).rc --input-format=rc --codepage=65001 -o $(PROJECT).res -O coff -	$(WINCC64_PREFIX)-gcc $(PROJECT).c $(PROJECT).res -o $(PROJECT).exe   -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -Wformat -O2 +	$(WINCC64_PREFIX)-gcc $(PROJECT).c $(PROJECT).res -o $(PROJECT).exe   -Wall -pedantic -MP -MD -std=gnu99 -Werror=format-security -Wformat -O2  	$(WINCC64_PREFIX)-strip $(PROJECT).exe  sercp.w32: $(PROJECT).c  	rm -f $(PROJECT).res  	$(WINCC_PREFIX)-windres -i $(PROJECT).rc --input-format=rc --codepage=65001 -o $(PROJECT).res -O coff -	$(WINCC_PREFIX)-gcc $(PROJECT).res $(PROJECT).c -o $(PROJECT)32.exe -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -Wformat -O2 +	$(WINCC_PREFIX)-gcc $(PROJECT).res $(PROJECT).c -o $(PROJECT)32.exe -Wall -pedantic -MP -MD -std=gnu99 -Werror=format-security -Wformat -O2  	$(WINCC_PREFIX)-strip $(PROJECT)32.exe  debug:	$(PROJECT).c -	$(CC) $(PROJECT).c -o $(PROJECT) -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -g -O0 -Wformat +	$(CC) $(PROJECT).c -o $(PROJECT) -Wall -pedantic -MP -MD -std=gnu99 -Werror=format-security -g -O0 -Wformat  clean:  	rm -f $(PROJECT) $(PROJECT).d $(PROJECT).o $(PROJECT).res $(PROJECT)*.d $(PROJECT)*.exe @@ -24,7 +24,6 @@  	#include <stdio.h>  	#include <stdint.h>  	#include <io.h> -	#include <fcntl.h>  	#include <windows.h>  	#include <getopt.h>  	#include <strings.h> @@ -65,7 +64,7 @@  #define FALSE 0  #define true 1  #define TRUE 1 -const char* _version = "v0.3.4"; +const char* _version = "v0.3.5";  // SERIAL  FILE *tapout_fd = NULL;  int is_outfile = 0; @@ -86,6 +85,10 @@ int scp = 0;  int is_scp_read = 0;  int is_continue = 1; +// prototypes + +void sleep_ms(int milliseconds); +  char SERIALDEVICE[128] = {  #ifdef _WIN32  	"\\\\.\\COM1" @@ -169,7 +172,7 @@ void TestArgs (int argc, char *argv[])  #else  				sprintf(SERIALDEVICE, "%s", optarg);  #endif -								printf ("Serial port: %s\n", SERIALDEVICE); +//				printf ("Serial port: %s\n", SERIALDEVICE);  				break;  			case 'b':  				baud_rate = atoi(optarg); @@ -204,6 +207,7 @@ void TestArgs (int argc, char *argv[])  void FlushSerialPort() {  if (serial_fd) { +	sleep_ms(20);  #ifdef _WIN32  		PurgeComm(serial_fd, PURGE_RXABORT| PURGE_TXABORT | PURGE_RXCLEAR | PURGE_TXCLEAR);  #else @@ -652,6 +656,8 @@ void sercpSend(void) {  		}  	}  	printf("\nFile sent...\n"); +	// FIXME na __APPLE__ tady pomaha pockat +	// sleep_ms(5000);  	fclose(tap_fd);  } @@ -699,13 +705,14 @@ int OpenUart() {  #else  	struct termios oldtio, newtio;  	/* open the device to be non-blocking (read will return immediatly) */ -	serial_fd = open(SERIALDEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); +	serial_fd = open(SERIALDEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK | O_NDELAY);  	if (serial_fd < 0) {  		perror(SERIALDEVICE);  		return(-1);  	}  	tcgetattr(serial_fd, &oldtio); /* save current port settings */  	bzero(&newtio, sizeof (newtio)); +	cfmakeraw(&newtio);  	switch (baud_rate){  		case 115200:  			newtio.c_cflag = B115200; @@ -736,7 +743,6 @@ int OpenUart() {        newtio.c_cflag = B38400;        break;  	} -	cfmakeraw(&newtio);  	cfsetspeed(&newtio, baud_rate);  #if defined (__APPLE__) || defined (BSD)  // 	newtio.c_cflag |= CS8 | CLOCAL | CREAD | CCTS_OFLOW | CRTS_IFLOW; @@ -751,6 +757,7 @@ int OpenUart() {  	newtio.c_cc[VMIN] = 0;  	newtio.c_cc[VTIME] = 0;  	tcsetattr(serial_fd, TCSANOW, &newtio); +	sleep_ms(20);  	tcflush(serial_fd, TCIOFLUSH);  	return 0;  #endif @@ -1,8 +1,8 @@  // RC file, codepage utf-8 !!!!!  #include <windows.h> // include for version info constants  1 VERSIONINFO -FILEVERSION 0,3,4,0 -PRODUCTVERSION 0,3,4,0 +FILEVERSION 0,3,5,0 +PRODUCTVERSION 0,3,5,0  FILETYPE VFT_APP  {    BLOCK "StringFileInfo" @@ -10,14 +10,14 @@ FILETYPE VFT_APP  		 BLOCK "040904E4"  		 {  			 VALUE "CompanyName", "vym.cz" -			 VALUE "FileVersion", "0.3.4" +			 VALUE "FileVersion", "0.3.5"  			 VALUE "FileDescription", "sercp - serial copy for ZX Spectrum"  			 VALUE "InternalName", "sercp"  			 VALUE "LegalCopyright", "GNU GPL v3 or above"  			 VALUE "LegalTrademarks", "Pavel Vymetálek"  			 VALUE "OriginalFilename", "sercp"  			 VALUE "ProductName", "sercp" -			 VALUE "ProductVersion", "0.3.4" +			 VALUE "ProductVersion", "0.3.5"  			 VALUE "Build environment", "Linux: Mingw64, x86_64"  		 }  	 } | 
