From c658bf9a9e38731e08a0526972c0c911c1980c65 Mon Sep 17 00:00:00 2001 From: Pavel Vymetálek Date: Wed, 27 Feb 2019 09:49:13 +0100 Subject: Doplněn odkaz GNU/GPL, řízení toku RTS/CTS na Windows, doplěn .rc soubor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 29 ++++++++++++++++++++--------- TODO | 19 ++++++++++++++++++- sercp.c | 63 ++++++++++++++++++++++++++++----------------------------------- sercp.rc | 29 +++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 45 deletions(-) create mode 100644 sercp.rc diff --git a/Makefile b/Makefile index 3163e3b..4cb7232 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,34 @@ PROJECT=sercp -all: $(PROJECT) $(PROJECT).w32 $(PROJECT).w64 +PREFIX=/usr/local +CC=gcc +WINCC_PREFIX=i686-w64-mingw32 +WINCC64_PREFIX=x86_64-w64-mingw32 + +all: $(PROJECT) + +windows: $(PROJECT).w32 $(PROJECT).w64 sercp: $(PROJECT).c - gcc $(PROJECT).c -o $(PROJECT) -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -O2 + $(CC) $(PROJECT).c -o $(PROJECT) -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -O2 + +install: $(PROJECT) + install -d $(DESTDIR)$(PREFIX)/bin/ + install -m 755 $< $(DESTDIR)$(PREFIX)/bin/ sercp.w64: $(PROJECT).c rm -f $(PROJECT).res - x86_64-w64-mingw32-windres -i $(PROJECT).rc --input-format=rc --codepage=65001 -o $(PROJECT).res -O coff - x86_64-w64-mingw32-gcc $(PROJECT).c $(PROJECT).res -o $(PROJECT).exe -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -O2 - x86_64-w64-mingw32-strip $(PROJECT).exe + $(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 -O2 + $(WINCC64_PREFIX)-strip $(PROJECT).exe sercp.w32: $(PROJECT).c rm -f $(PROJECT).res - i686-w64-mingw32-windres -i $(PROJECT).rc --input-format=rc --codepage=65001 -o $(PROJECT).res -O coff - i686-w64-mingw32-gcc $(PROJECT).res $(PROJECT).c -o $(PROJECT)32.exe -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -O2 - i686-w64-mingw32-strip $(PROJECT)32.exe + $(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 -O2 + $(WINCC_PREFIX)-strip $(PROJECT)32.exe debug: $(PROJECT).c - gcc $(PROJECT).c -o $(PROJECT) -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -g -O0 + $(CC) $(PROJECT).c -o $(PROJECT) -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -g -O0 clean: rm -f $(PROJECT) $(PROJECT).d $(PROJECT).o $(PROJECT).res $(PROJECT)*.d $(PROJECT)*.exe diff --git a/TODO b/TODO index a6e6fd5..120867c 100644 --- a/TODO +++ b/TODO @@ -3,7 +3,24 @@ 2019-01-09 + Asi udělat fork jen pro sercp tak jako se bude program jmenovat v Esxdosu - - Udělat kontrolu jmena souboru, aby vyhovoval formátu 8.3 pro Esxdos + + Udělat kontrolu jmena souboru, aby vyhovoval formátu 8.3 pro Esxdos x NE udělat přepínač pro dva stopbity při vysílání do ZX + udělat HW řízení toku při zápisu? Aby se nemuselo čekat déle, než je třeba? + + +VÝHODY +* funguje :-) +* nejrychlejší způsob jak dostat do ZX malý soubor +* nepotřebuje PC - přenos mezi dvěma Spectry + + +NEVÝHODY +* nemá LFN (esxdos) - ale sercp je na to připraven :-) +* nenastavuje datum a čas souboru - esxdosu chybí api +* nejde obnovit přenos +* zatím není na ZX psáno portabilně - na jiné diskové systémy + +PC program +* zkracuje na 8.3 automaticky ;-) +* chybí GUI diff --git a/sercp.c b/sercp.c index dfa2eaf..0055716 100644 --- a/sercp.c +++ b/sercp.c @@ -1,11 +1,22 @@ - +/* + * sercp - serial copy for transfering file to/from ZX Spectrum 128 AY's RS232 + * Copyright (c) 2018-2019 Pavel Vymetalek + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version (GPL-3.0-or-later). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #ifdef __WIN32 -// #include -// #include -// #include -// #include - #include #include #include @@ -109,6 +120,7 @@ void usage(void) { printf ("sercp %s (c)2018-2019 Pavel Vymetalek \n", _version); printf ("serial copy for transfering file to/from ZX Spectrum 128 AY's RS232\n"); printf ("Uses 1109bytes of fileinfo - blocks sums, filename, etc.\n"); + printf ("More info at https://vym.cz/sercp/\n"); printf ("Usage:\nsercp [-v] [-h] -d /dev/serial [-b baud_rate] [-w time] [-r] \n"); printf ("\t-v, --version\tShow version info\n"); printf ("\t-h, --help\tShow this text\n"); @@ -118,7 +130,7 @@ void usage(void) { printf ("\t-d, --device\tSerial communication device\n"); #endif printf ("\t-b, --baud\tSet the communication speed. Default 38400Bd\n"); - printf ("\t-w, --wait\tWaiting in milliseconds between transmitted blocks. Default is -w 800 milliseconds\n"); + printf ("\t-w, --wait\tWaiting in milliseconds between transmitted blocks.\n\t\t\tDefault is -w 800 ms\n"); printf ("\t-r, --read\tRead file from serial port\n"); } @@ -148,7 +160,6 @@ void TestArgs (int argc, char *argv[]) #ifdef __WIN32 sprintf(MODEMDEVICE, "\\\\.\\%s", optarg); #else -// strncpy(MODEMDEVICE, optarg, strlen(optarg)); sprintf(MODEMDEVICE, "%s", optarg); #endif printf ("Serial port: %s\n", MODEMDEVICE); @@ -203,15 +214,9 @@ void uSleep(int waitTime) { #endif } -// cross-platform sleep function void sleep_ms(int milliseconds) { #ifdef WIN32 Sleep(milliseconds); -// #elif _POSIX_C_SOURCE >= 199309L -// struct timespec ts; -// ts.tv_sec = milliseconds / 1000; -// ts.tv_nsec = (milliseconds % 1000) * 1000000; -// nanosleep(&ts, NULL); #else usleep(milliseconds * 1000); #endif @@ -473,16 +478,6 @@ void sercpRecv(void) { break; } // } - /*else if (length > 16384) { -#ifdef __WIN32 - ReadFile(serial_fd, p_buff, 16384, &ulNumBytes, NULL); - len = (uint16_t)ulNumBytes; -#else - len = read (serial_fd, p_buff, 16384); -#endif - printf("Nejaky bordel. Koncim...\n"); - break; - }*/ } } if (tapout_fd) { @@ -515,16 +510,12 @@ void sercpSend(void) { no = stat(sercp_file, &st); if (no != 0) { -// err = errno; -// error(1, err, "can't stat input file"); printf ("can't stat input file\n"); exit (EXIT_FAILURE); } tap_fd = fopen(sercp_file, "rb"); if (tap_fd == NULL) { -// err = errno; -// error(1, err, "can't open input file"); printf ("can't open input file\n"); exit (EXIT_FAILURE); } @@ -567,7 +558,6 @@ void sercpSend(void) { #endif printf("Fileinfo sent with filename: %s\n", bname); // TODO Cekat pauzu mezi bloky -// uSleep (wait_ms * 1000); sleep_ms(wait_ms); rewind(tap_fd); // prenaseny soubor na zacatek @@ -582,7 +572,6 @@ void sercpSend(void) { #ifdef __WIN32 WriteFile(serial_fd, (void*)p_buff, sent_size, &ulNumBytes, NULL); odeslano = (size_t)ulNumBytes; -// sleep_ms(wait_ms); #else odeslano = write (serial_fd, (void*)p_buff, sent_size); tcdrain(serial_fd); @@ -595,12 +584,16 @@ void sercpSend(void) { } DoProgress(overall_sent, st.st_size, PROGRESS_PERCENT); } -// uSleep (wait_ms * 1000); sleep_ms(wait_ms); file_len -= len; } - printf("\nFile sent...\n"); + if (is_continue) { + printf("\nFile sent...\n"); + } else { + printf("\nend...\n"); + } + fclose(tap_fd); } @@ -623,9 +616,10 @@ int OpenUart() { sDCB.fBinary = TRUE; sDCB.StopBits = ONESTOPBIT; sDCB.fAbortOnError = TRUE; - sDCB.fOutxCtsFlow = FALSE; sDCB.fOutxDsrFlow = FALSE; -// sDCB.fDtrControl = DTR_CONTROL_ENABLE; + sDCB.fDtrControl = DTR_CONTROL_DISABLE; + sDCB.fRtsControl = RTS_CONTROL_ENABLE; + sDCB.fOutxCtsFlow = TRUE; if (SetCommState(serial_fd, &sDCB) == 0) { return (-1); } @@ -633,7 +627,6 @@ int OpenUart() { if (GetCommTimeouts(serial_fd, &sCommTimeouts) == 0) { return (-1); } - sCommTimeouts.ReadIntervalTimeout = MAXDWORD; //80 sCommTimeouts.ReadTotalTimeoutConstant = 00; sCommTimeouts.ReadTotalTimeoutMultiplier = 00; diff --git a/sercp.rc b/sercp.rc new file mode 100644 index 0000000..c334fdd --- /dev/null +++ b/sercp.rc @@ -0,0 +1,29 @@ +// RC file, codepage utf-8 !!!!! +#include // include for version info constants +//A ICON "compiler.ico" +1 VERSIONINFO +FILEVERSION 0,2,2,0 +PRODUCTVERSION 0,2,2,0 +FILETYPE VFT_APP +{ + BLOCK "StringFileInfo" + { + BLOCK "040904E4" + { + VALUE "CompanyName", "Pavel Vymetálek vym.cz" + VALUE "FileVersion", "0.2.2" + VALUE "FileDescription", "sercp - serial copy for ZX Spectrum" + VALUE "InternalName", "sercp" + VALUE "LegalCopyright", "GNU GPL v2 or above" + VALUE "LegalTrademarks", "pavel@vym.cz" + VALUE "OriginalFilename", "sercp" + VALUE "ProductName", "sercp" + VALUE "ProductVersion", "0.2.2" + VALUE "Build environment", "Linux: Mingw64, x86_64" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 65001 + } +} -- cgit