S
ssndk123
Hi,
Using the UserPort program that changes permissions in XP so that I am
able to write directly to the parallel port using assembler..
I'm trying to send out square wave pulses for x number of seconds. I'm
able to write and read from the parallel port, but after a few reads
and writes it crashes... how many reads and writes before it crashes
is not always the same.. sometimes it crashes at the first write or
read.. other times it can do 10 reads or writes...
Is windows halting my program in one of it's hickups and making my
program crash? I don't mind that the pulses are not always space
exactly the same in between.. so I don't need realtime processing..
Has anyone here tried this? Or do you know how to make sure the
program doens't crash?
Thanks,
Soren
Heres the code: It only demonstrate a few reads and writes.. if I put
it in a for/while loop, it'll certainly crash after a few iterations.
You need to start UserPort (http://www.embeddedtronics.com/public/
Electronics/minidaq/userport/UserPort.zip)
To enable direct write to the ports.
----------------------------------------------------
#include <iostream>
#include "windows.h"
using namespace std;
inline unsigned int
inb(unsigned short port)
{
unsigned char _v;
__asm__ __volatile__ ("inb %w1,%b0"
:"=a" (_v)
:"d" (port), "0" (0));
printf("Hello check\n");
return(_v);
}
inline void
outb(unsigned char value,
unsigned short port)
{
__asm__ __volatile__ ("outb %b0,%w1"
:/* no writes */
:"a" (value), "d" (port));
}
int main()
{
int i;
int c;
int port = 0x378;
cout << "Press enter to begin: ";
cin >> i;
//outb(0, port+0); // write to parallel port
Sleep(100);
c = inb(port+0);
Sleep(100);
printf("Val = : %d", c);
outb(255, port+0);
Sleep(100);
c = inb(port+0);
printf("Val = : %d", c);
return 0;
}
Using the UserPort program that changes permissions in XP so that I am
able to write directly to the parallel port using assembler..
I'm trying to send out square wave pulses for x number of seconds. I'm
able to write and read from the parallel port, but after a few reads
and writes it crashes... how many reads and writes before it crashes
is not always the same.. sometimes it crashes at the first write or
read.. other times it can do 10 reads or writes...
Is windows halting my program in one of it's hickups and making my
program crash? I don't mind that the pulses are not always space
exactly the same in between.. so I don't need realtime processing..
Has anyone here tried this? Or do you know how to make sure the
program doens't crash?
Thanks,
Soren
Heres the code: It only demonstrate a few reads and writes.. if I put
it in a for/while loop, it'll certainly crash after a few iterations.
You need to start UserPort (http://www.embeddedtronics.com/public/
Electronics/minidaq/userport/UserPort.zip)
To enable direct write to the ports.
----------------------------------------------------
#include <iostream>
#include "windows.h"
using namespace std;
inline unsigned int
inb(unsigned short port)
{
unsigned char _v;
__asm__ __volatile__ ("inb %w1,%b0"
:"=a" (_v)
:"d" (port), "0" (0));
printf("Hello check\n");
return(_v);
}
inline void
outb(unsigned char value,
unsigned short port)
{
__asm__ __volatile__ ("outb %b0,%w1"
:/* no writes */
:"a" (value), "d" (port));
}
int main()
{
int i;
int c;
int port = 0x378;
cout << "Press enter to begin: ";
cin >> i;
//outb(0, port+0); // write to parallel port
Sleep(100);
c = inb(port+0);
Sleep(100);
printf("Val = : %d", c);
outb(255, port+0);
Sleep(100);
c = inb(port+0);
printf("Val = : %d", c);
return 0;
}