mirror of
https://github.com/vivier/EMILE.git
synced 2024-09-08 19:54:38 +00:00
Use EM06 header
This commit is contained in:
parent
e44fa532f2
commit
8d2c64e23f
@ -15,8 +15,7 @@
|
|||||||
|
|
||||||
#include "libemile.h"
|
#include "libemile.h"
|
||||||
|
|
||||||
static char *parity[3] = { "None", "Odd", "Even" };
|
static char parity[] = { 'n', 'o', 'e' };
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ARG_NONE = 0,
|
ARG_NONE = 0,
|
||||||
ARG_HELP = 'h',
|
ARG_HELP = 'h',
|
||||||
@ -56,6 +55,12 @@ static struct option long_options[] =
|
|||||||
{NULL, 0, NULL, 0 },
|
{NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
STDOUT_VGA = 1,
|
||||||
|
STDOUT_MODEM = 2,
|
||||||
|
STDOUT_PRINTER = 4,
|
||||||
|
};
|
||||||
|
|
||||||
static void usage(int argc, char** argv)
|
static void usage(int argc, char** argv)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage:\n");
|
fprintf(stderr, "Usage:\n");
|
||||||
@ -81,17 +86,9 @@ static void usage(int argc, char** argv)
|
|||||||
|
|
||||||
static int display_output(char* image)
|
static int display_output(char* image)
|
||||||
{
|
{
|
||||||
unsigned int console_mask;
|
|
||||||
unsigned int bitrate0;
|
|
||||||
int datasize0;
|
|
||||||
int parity0;
|
|
||||||
int stopbits0;
|
|
||||||
unsigned int bitrate1;
|
|
||||||
int datasize1;
|
|
||||||
int parity1;
|
|
||||||
int stopbits1;
|
|
||||||
int gestaltid;
|
|
||||||
int drive, second, size;
|
int drive, second, size;
|
||||||
|
char *configuration;
|
||||||
|
char property[256];
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
@ -120,11 +117,8 @@ static int display_output(char* image)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = emile_second_get_output(fd, &console_mask, &bitrate0,
|
configuration = emile_second_get_configuration(fd);
|
||||||
&datasize0, &parity0, &stopbits0,
|
if (configuration == NULL)
|
||||||
&bitrate1, &datasize1, &parity1,
|
|
||||||
&stopbits1, &gestaltid);
|
|
||||||
if (ret)
|
|
||||||
{
|
{
|
||||||
perror("Cannot read header");
|
perror("Cannot read header");
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -133,32 +127,28 @@ static int display_output(char* image)
|
|||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
if (console_mask & STDOUT_VGA)
|
if (emile_second_get_property(configuration, "vga", property) == 0)
|
||||||
printf("Output to display enabled\n");
|
printf("Output to display enabled (%s)\n", property);
|
||||||
else
|
else
|
||||||
printf("Output to display disabled\n");
|
printf("Output to display disabled\n");
|
||||||
|
|
||||||
if (console_mask & STDOUT_SERIAL0)
|
if (emile_second_get_property(configuration, "modem", property) == 0)
|
||||||
printf("Output to serial port 0 (modem) enabled\n");
|
printf("Output to serial port 0 (modem) enabled (%s)\n", property);
|
||||||
else
|
else
|
||||||
printf("Output to serial port 0 (modem) disabled\n");
|
printf("Output to serial port 0 (modem) disabled\n");
|
||||||
|
|
||||||
printf(" Bitrate: %d Datasize: %d Parity: %s Stopbits: %d\n",
|
if (emile_second_get_property(configuration, "printer", property) == 0)
|
||||||
bitrate0, datasize0, parity[parity0], stopbits0);
|
printf("Output to serial port 1 (printer) enabled (%s)\n", property);
|
||||||
|
|
||||||
if (console_mask & STDOUT_SERIAL1)
|
|
||||||
printf("Output to serial port 1 (printer) enabled\n");
|
|
||||||
else
|
else
|
||||||
printf("Output to serial port 1 (printer) disabled\n");
|
printf("Output to serial port 1 (printer) disabled\n");
|
||||||
|
|
||||||
printf(" Bitrate: %d Datasize: %d Parity: %s Stopbits: %d\n",
|
if (emile_second_get_property(configuration, "gestaltID", property) == 0)
|
||||||
bitrate1, datasize1, parity[parity1], stopbits1);
|
printf("Force Gestalt ID to %ld\n", strtol(property, NULL, 0));
|
||||||
|
|
||||||
if (gestaltid)
|
|
||||||
printf("Force Gestalt ID to %d\n", gestaltid);
|
|
||||||
else
|
else
|
||||||
printf("Gestalt ID is not modified\n");
|
printf("Gestalt ID is not modified\n");
|
||||||
|
|
||||||
|
free(configuration);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +161,8 @@ static int set_output(char* image,
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
|
char *configuration;
|
||||||
|
char property[32];
|
||||||
|
|
||||||
fd = open(image, O_RDWR);
|
fd = open(image, O_RDWR);
|
||||||
|
|
||||||
@ -188,10 +180,51 @@ static int set_output(char* image,
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = emile_second_set_output(fd, enable_mask, disable_mask,
|
configuration = emile_second_get_configuration(fd);
|
||||||
bitrate0, datasize0, parity0, stopbits0,
|
if (configuration == NULL)
|
||||||
bitrate1, datasize1, parity1, stopbits1,
|
{
|
||||||
gestaltid);
|
perror("Cannot read header");
|
||||||
|
close(fd);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disable_mask & STDOUT_VGA)
|
||||||
|
emile_second_remove_property(configuration, "vga");
|
||||||
|
if (disable_mask & STDOUT_MODEM)
|
||||||
|
emile_second_remove_property(configuration, "modem");
|
||||||
|
if (disable_mask & STDOUT_PRINTER)
|
||||||
|
emile_second_remove_property(configuration, "printer");
|
||||||
|
|
||||||
|
if (enable_mask & STDOUT_VGA)
|
||||||
|
emile_second_set_property(configuration, "vga", "default");
|
||||||
|
if (enable_mask & STDOUT_MODEM)
|
||||||
|
{
|
||||||
|
sprintf(property, "%d%c%d+%d", bitrate0, parity[parity0], datasize0, stopbits0);
|
||||||
|
emile_second_set_property(configuration, "modem", property);
|
||||||
|
}
|
||||||
|
if (enable_mask & STDOUT_PRINTER)
|
||||||
|
{
|
||||||
|
sprintf(property, "%d%c%d+%d", bitrate1, parity[parity1], datasize1, stopbits1);
|
||||||
|
emile_second_set_property(configuration, "printer", property);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gestaltid == 0)
|
||||||
|
emile_second_remove_property(configuration, "gestaltID");
|
||||||
|
else if (gestaltid != -1)
|
||||||
|
{
|
||||||
|
sprintf(property, "0x%x", gestaltid);
|
||||||
|
emile_second_set_property(configuration, "gestaltID", property);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lseek(fd, FIRST_LEVEL_SIZE, SEEK_SET);
|
||||||
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
perror("Cannot go to buffer offset");
|
||||||
|
close(fd);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = emile_second_set_configuration(fd, configuration);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
perror("Cannot write header");
|
perror("Cannot write header");
|
||||||
@ -199,6 +232,7 @@ static int set_output(char* image,
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
free(configuration);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -213,10 +247,10 @@ int main(int argc, char** argv)
|
|||||||
unsigned int disable_mask = 0;
|
unsigned int disable_mask = 0;
|
||||||
unsigned int last = 0;
|
unsigned int last = 0;
|
||||||
int width = 0, height = 0 , depth = 0;
|
int width = 0, height = 0 , depth = 0;
|
||||||
unsigned int bitrate0 = 0, bitrate1 = 0;
|
unsigned int bitrate0 = 9600, bitrate1 = 9600;
|
||||||
int datasize0 = -1, datasize1 = -1;
|
int datasize0 = 8, datasize1 = 8;
|
||||||
int stopbits0 = -1, stopbits1 = -1;
|
int stopbits0 = 1, stopbits1 = 1;
|
||||||
int parity0 = -1, parity1 = -1;
|
int parity0 = 0, parity1 = 0;
|
||||||
int gestaltid = -1;
|
int gestaltid = -1;
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
@ -239,11 +273,11 @@ int main(int argc, char** argv)
|
|||||||
last = 0;
|
last = 0;
|
||||||
break;
|
break;
|
||||||
case ARG_NOMODEM:
|
case ARG_NOMODEM:
|
||||||
disable_mask |= STDOUT_SERIAL0;
|
disable_mask |= STDOUT_MODEM;
|
||||||
last = 0;
|
last = 0;
|
||||||
break;
|
break;
|
||||||
case ARG_NOPRINTER:
|
case ARG_NOPRINTER:
|
||||||
disable_mask |= STDOUT_SERIAL1;
|
disable_mask |= STDOUT_PRINTER;
|
||||||
last = 0;
|
last = 0;
|
||||||
break;
|
break;
|
||||||
case ARG_DISPLAY:
|
case ARG_DISPLAY:
|
||||||
@ -251,12 +285,12 @@ int main(int argc, char** argv)
|
|||||||
last = STDOUT_VGA;
|
last = STDOUT_VGA;
|
||||||
break;
|
break;
|
||||||
case ARG_MODEM:
|
case ARG_MODEM:
|
||||||
enable_mask |= STDOUT_SERIAL0;
|
enable_mask |= STDOUT_MODEM;
|
||||||
last = STDOUT_SERIAL0;
|
last = STDOUT_MODEM;
|
||||||
break;
|
break;
|
||||||
case ARG_PRINTER:
|
case ARG_PRINTER:
|
||||||
enable_mask |= STDOUT_SERIAL1;
|
enable_mask |= STDOUT_PRINTER;
|
||||||
last = STDOUT_SERIAL1;
|
last = STDOUT_PRINTER;
|
||||||
break;
|
break;
|
||||||
case ARG_WIDTH:
|
case ARG_WIDTH:
|
||||||
if (last != STDOUT_VGA)
|
if (last != STDOUT_VGA)
|
||||||
@ -283,9 +317,9 @@ int main(int argc, char** argv)
|
|||||||
depth = atol(optarg);
|
depth = atol(optarg);
|
||||||
break;
|
break;
|
||||||
case ARG_BITRATE:
|
case ARG_BITRATE:
|
||||||
if (last == STDOUT_SERIAL0)
|
if (last == STDOUT_MODEM)
|
||||||
bitrate0 = atol(optarg);
|
bitrate0 = atol(optarg);
|
||||||
else if (last == STDOUT_SERIAL1)
|
else if (last == STDOUT_PRINTER)
|
||||||
bitrate1 = atol(optarg);
|
bitrate1 = atol(optarg);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -295,9 +329,9 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ARG_DATASIZE:
|
case ARG_DATASIZE:
|
||||||
if (last == STDOUT_SERIAL0)
|
if (last == STDOUT_MODEM)
|
||||||
datasize0 = atol(optarg);
|
datasize0 = atol(optarg);
|
||||||
else if (last == STDOUT_SERIAL1)
|
else if (last == STDOUT_PRINTER)
|
||||||
datasize1 = atol(optarg);
|
datasize1 = atol(optarg);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -307,9 +341,9 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ARG_PARITY:
|
case ARG_PARITY:
|
||||||
if (last == STDOUT_SERIAL0)
|
if (last == STDOUT_MODEM)
|
||||||
parity0 = atol(optarg);
|
parity0 = atol(optarg);
|
||||||
else if (last == STDOUT_SERIAL1)
|
else if (last == STDOUT_PRINTER)
|
||||||
parity1 = atol(optarg);
|
parity1 = atol(optarg);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -319,9 +353,9 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ARG_STOPBITS:
|
case ARG_STOPBITS:
|
||||||
if (last == STDOUT_SERIAL0)
|
if (last == STDOUT_MODEM)
|
||||||
stopbits0 = atol(optarg);
|
stopbits0 = atol(optarg);
|
||||||
else if (last == STDOUT_SERIAL1)
|
else if (last == STDOUT_PRINTER)
|
||||||
stopbits1 = atol(optarg);
|
stopbits1 = atol(optarg);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user