Tenacious wrote:
Does anyone have experience accessing the parallel, serial, and game ports from within a basic program? I want to move data into and out of these ports.
Thanks Again
You will probably not find much information of accessing Hardware from Basic programs.
It is possible as long as the basic can access the system API.
But using C as programming language is a lot better when it comes to Hardware access.
Here is a simple Example Program that opens the parallel.device and send a string of data to it.
#include <stdio.h>
#include <stdlib.h>
#include <proto/exec.h>
#include <devices/parallel.h>
int main(int argc, char *argv[])
{
struct IOExtPar * Parallelport;
struct MsgPort * ParallelMsgPort;
BYTE Returnvalue;
if(ParallelMsgPort = CreateMsgPort())
{
if(Parallelport = (struct IOExtPar *) CreateIORequest(ParallelMsgPort, sizeof(struct IOExtPar)))
{
Parallelport->io_ParFlags = PARF_SHARED;
}
else
{printf("CreateIORequest failed\n");}
}
else
{printf("CreateMsgPort failed\n");}
printf("Open Parallelport...\n");
Returnvalue = OpenDevice("parallel.device",0L,(struct IORequest *)Parallelport,0);
if(Returnvalue == 0)
{
printf("Opening Parallel Port successful\n");
}
else
{
printf("An Error accured.\n");
}
printf("Press any key to send Data...\n");
Parallelport->IOPar.io_Length = -1;
Parallelport->IOPar.io_Data = (APTR)"Parallel lines cross 7 times...";
Parallelport->IOPar.io_Command = CMD_WRITE;
DoIO((struct IORequest *)Parallelport);
printf("Any key to quit...\n");
getchar();
CloseDevice((struct IORequest *)Parallelport);
DeleteMsgPort(ParallelMsgPort);
DeleteIORequest((struct IORequest *)Parallelport);
printf("Any key to quit...\n");
getchar();
return Returnvalue;
}