From 034a1e66b8c8ed9f0282b414179874a38d9196d1 Mon Sep 17 00:00:00 2001 From: Stefan Ziegler Date: Wed, 7 Nov 2018 23:18:44 +0100 Subject: Anpassung Demo-Programme und Vorträge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/demo-programme/raider.c | 109 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 content/demo-programme/raider.c (limited to 'content/demo-programme/raider.c') diff --git a/content/demo-programme/raider.c b/content/demo-programme/raider.c new file mode 100644 index 0000000..6669c2b --- /dev/null +++ b/content/demo-programme/raider.c @@ -0,0 +1,109 @@ +#include +#include +#include + +#define SHOW(st,bits) printf(#bits" %s\n", ( st & bits) ?"on":"off") + +void dump_cap(int cap) +{ + + SHOW(cap,CAP1284_RAW); + SHOW(cap,CAP1284_NIBBLE); + SHOW(cap,CAP1284_BYTE); + SHOW(cap,CAP1284_COMPAT); + SHOW(cap,CAP1284_BECP); + SHOW(cap,CAP1284_ECP); + SHOW(cap,CAP1284_ECPRLE); + SHOW(cap,CAP1284_ECPSWE); + SHOW(cap,CAP1284_EPP); + SHOW(cap,CAP1284_EPPSL); + SHOW(cap,CAP1284_EPPSWE); + SHOW(cap,CAP1284_IRQ); + SHOW(cap,CAP1284_DMA) ; + + +} + + + +void pperror(int ret) +{ + switch(ret) + { + case E1284_NOMEM: + puts("There is not enough memory"); + break; + + case E1284_INVALIDPORT: + puts("The port is invalid"); + break; + + case E1284_SYS: + perror("E1284_SYS"); + break; + + default: + printf("unknown error %d",ret); + } + +} + +int main() +{ + int ret; + int fd; + int flags,cap,i; + unsigned char dat; + + struct parport_list *plist=calloc(1,sizeof(*plist)); + struct parport *pport; + + + ret = ieee1284_find_ports( plist, 0); + + if ( ( ret != E1284_OK ) || (plist->portc < 1) ) /* cannot find parports */ + return -1; + + pport = plist->portv[0]; + + + //flags=F1284_EXCL; //causes CLAIM to fail is mod lp is loaded + flags=0; + printf("going to open %s\n",pport->filename); + ret=ieee1284_open(pport,flags,&cap); + if (ret != E1284_OK ) + goto no_open; + + // + dump_cap(cap); + + ret = ieee1284_claim ( pport ); + if ( ret != E1284_OK ) + { + printf("could not claim port\n"); + pperror( ret ); + goto no_claim; + } + + /* set data direction */ + ieee1284_data_dir( pport,0); + + + for(i=0;i<8;i++) + { + dat=1<