Basically, how would one take this code (written for a parallel port) and change it to make it work with a serial port?
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
#define base 0x378 /* /dev/lp0 */
main(int argc, char **argv) {
int value;
if (argc!=2)
printf("Enter a number between 0 and 255.\n"), exit(1);
if (sscanf(argv[1],"%i",&value)!=1)
printf("Parameter is not a number.\n"), exit(1);
if ((value<0) || (value>255))
printf("Enter a number between 0 and 255.\n"), exit(1);
if (ioperm(base,1,1))
perror("ioperm");
printf("Setting base %x to value %d\n", base, value);
outb((unsigned char)value, base);
}
Small project I'm working on and I don't want to ruin any hardware. I know they have different numbers of pins and I'm not sure how to adjust it to run with a serial port.