473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Writes to parallel port using assembler, sometimes crashes.

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;
}
Jun 27 '08 #1
1 2854
ss******@gmail.com wrote:
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..

[redacted]
Wrong group. Try one with "microsoft" or "windows" in its name.

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Diego Solis | last post by:
Hi people, I need to write a C# program which communicates with a thermal printer. After a search for the web I found that a way to comunicate with the ports is calling the kernel32.dll, which...
4
by: Joseph Suprenant | last post by:
I am looking to read a byte or write a byte on the parallel port in linux. I am using red hat 7.3. I tired using this but i couldnt get anywere. { unsigned char value; __asm__ volatile ("inb...
4
by: David | last post by:
I'm wondering if python is capable of fairly precise timing and also sending data out the parallel port. For example ; making a 7.5 KHz square wave come out of one of the data pins on the...
9
by: MNQ | last post by:
Hi All I want to use my parallel port of my PC to control some external devices. I am writing a program in ANSI C using the PacificC compiler. What I need to know is how to access the parallel...
11
by: Isaac T Alston | last post by:
Basically, I'm thinking about building a robot which can be controlled by programs which I write, I'm going to interface to the robot through the parallel port (like in this tutorial here:...
12
by: david.brown.0 | last post by:
I'm trying to make a Java program access a parallel port. Java's comm API does not provide me with the control I need. I need to be able to write to the data and control pins and read the status...
23
by: Marco | last post by:
Could anyone please tell me why the program has the following error? I copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm ...
4
by: Soren | last post by:
Hi, I want to control some motors using the parallel port.. however, my laptop does not have any parallel ports (very few do). What I do have is a USB->Parallel converter... I thought about...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.