summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Vymetálek <pavel@vym.cz>2019-01-09 07:55:39 +0100
committerPavel Vymetálek <pavel@vym.cz>2019-01-09 07:55:39 +0100
commitf7f617343a82139bd9f45a566cc626a0b35d3861 (patch)
tree49b286040fe2acde7561d20a9e0597b5531b89a2
parentdee8c4ce49131e11614436639701244328f4319d (diff)
downloadtaptoserial-f7f617343a82139bd9f45a566cc626a0b35d3861.tar.gz
Přidáno čekání mezi odesílanými bajty, další přenosové rychlosti
-rw-r--r--taptoser.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/taptoser.c b/taptoser.c
index 263e4d5..dd53d19 100644
--- a/taptoser.c
+++ b/taptoser.c
@@ -23,6 +23,7 @@ char MODEMDEVICE[64];
FILE *tapout_fd = NULL;
int is_outfile = 0;
int baud_rate = 0;
+int wait_us = 200;
#define FILENAME_LENGTH 400
char output_dump_file[FILENAME_LENGTH];
char tap_file[FILENAME_LENGTH];
@@ -48,6 +49,7 @@ void usage(void) {
printf ("\t-v, --version\tShow version info\n");
printf ("\t-h, --help\tShow this text\n");
printf ("\t-d, --device\tCommunication device\n");
+ printf ("\t-w, --wait\tWaiting in microseconds between transmitted bytes. Default is -w 200us\n");
printf ("\t-b, --baud\tSet the communication speed. 4800Bd, 9600Bd, 19200Bd and 57600Bd (default) are supported\n");
printf ("\t-B, --binary\tBinary output - received tap from ZX Spectrum will save without all tap's specific mishmash\n");
printf ("\t-o, --outfile\tOutput file. Usualy *.tap or *.bin with in --binary mode\n");
@@ -85,12 +87,13 @@ void TestArgs (int argc, char *argv[])
{"outfile", required_argument, NULL, 'o'},
{"device", required_argument, NULL, 'd'},
{"baud", required_argument, NULL, 'b'},
+ {"wait", required_argument, NULL, 'w'},
{"binary", no_argument, NULL, 'B'},
{"version", no_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{0, 0, 0, 0}
};
- c = getopt_long (argc, argv, "o:d:b:Bvh", long_options, &option_index);
+ c = getopt_long (argc, argv, "o:d:b:w:Bvh", long_options, &option_index);
if (c == -1) {
// konec parametru
break;
@@ -103,6 +106,9 @@ void TestArgs (int argc, char *argv[])
case 'b':
baud_rate = atoi(optarg);
break;
+ case 'w':
+ wait_us = atoi(optarg);
+ break;
case 'd':
strncpy(MODEMDEVICE, optarg, strlen(optarg));
// printf ("Serial port: %s\n", MODEMDEVICE);
@@ -334,7 +340,7 @@ void SendByte(unsigned char *p_dato) {
TestCts();
write (serial_fd, p_dato, 1);
// tcdrain(serial_fd); // better solution, but usleep at the next line is
- usleep (200); // faster solution, TODO change sleep time according to serial communication speed 200us is for 57600Bd
+ usleep (wait_us); // faster solution, TODO change sleep time according to serial communication speed 200us is for 57600Bd
}
void SendTap() {
@@ -373,7 +379,6 @@ void SendTap() {
for (out_indx = 0; out_indx < 19; out_indx++) {
SendByte(&header[out_indx]);
}
- usleep (400000);
} else {
if (h_len != no - 2) { /* zobrazuj iba bloky bez hl. */
len = no;
@@ -396,6 +401,7 @@ void SendTap() {
if (is_continue == 0) break;
}
printf ("\n");
+ usleep (800000);
}
}
fclose(tap_fd);
@@ -431,9 +437,15 @@ int main(int argc, char** argv, char** env)
baud_rate = 57600; // default speed
newtio.c_cflag = B57600 | CS8 | CLOCAL | CREAD | CSTOPB;// | CRTSCTS;
break;
+ case 115200:
+ newtio.c_cflag = B115200 | CS8 | CLOCAL | CREAD | CSTOPB | CRTSCTS;
+ break;
case 57600:
newtio.c_cflag = B57600 | CS8 | CLOCAL | CREAD | CSTOPB | CRTSCTS;
break;
+ case 38400:
+ newtio.c_cflag = B38400 | CS8 | CLOCAL | CREAD | CSTOPB | CRTSCTS; // dva stopbity jsou nastaveny vsude
+ break;
case 19200:
newtio.c_cflag = B19200 | CS8 | CLOCAL | CREAD | CSTOPB | CRTSCTS;
break;
@@ -443,6 +455,12 @@ int main(int argc, char** argv, char** env)
case 4800:
newtio.c_cflag = B4800 | CS8 | CLOCAL | CREAD | CSTOPB | CRTSCTS;
break;
+ case 2400:
+ newtio.c_cflag = B2400 | CS8 | CLOCAL | CREAD | CSTOPB | CRTSCTS;
+ break;
+ case 1200:
+ newtio.c_cflag = B1200 | CS8 | CLOCAL | CREAD | CSTOPB | CRTSCTS;
+ break;
}
printf ("Serial device: %s, communication speed is: %d Bd\n", MODEMDEVICE, baud_rate);
// newtio.c_iflag &= ~(IXON | IXOFF | IXANY); // vypne XON/XOFF