#include <stdio.h>
#include
<unistd.h> /* for sleep() */
#include
<stdint.h> /* for uintptr_t */
#include
<hw/inout.h> /* for in*() and out*() functions
*/
#include <sys/neutrino.h> /* for ThreadCtl()
*/
#include <sys/mman.h> /* for mmap_device_io()
*/
/* The Neutrino IO port used here corresponds to a
single register, which is
* one byte long
*/
#define PORT_LENGTH 1
/* The
first parallel port usually starts at 0x378. Each parallel port
is
* three bytes wide. The first byte is the Data
register, the second byte is
* the Status register, the
third byte is the Control register. */
#define
DATA_ADDRESS 0x378
#define CTRL_ADDRESS
0x37a
/* bit 2 = printer initialisation (high to
initialise)
* bit 4 = hardware IRQ (high to enable)
*/
#define INIT_BIT 0x04
#define
LOW 0x00
#define HIGH
0xFF
#define MAX_COUNT
60
/*
______________________________________________________________________
*/
int
main(
)
{
int
privity_err;
uintptr_t
ctrl_handle;
uintptr_t
data_handle;
int count;
/* Give
this thread root permissions to access the hardware
*/
privity_err = ThreadCtl( _NTO_TCTL_IO, NULL
);
if ( privity_err == -1
)
{
fprintf( stderr, "can‘t get root
permissions\n" );
return
-1;
}
/* Get a handle to the
parallel port‘s Control register */
ctrl_handle =
mmap_device_io( PORT_LENGTH, CTRL_ADDRESS );
/* Get a
handle to the parallel port‘s Data register */
data_handle
= mmap_device_io( PORT_LENGTH, DATA_ADDRESS );
for (
count = 0; count < MAX_COUNT; count++
)
{
/* Output a byte of lows to the data
lines */
out8( data_handle,
LOW);
out8( ctrl_handle, (LOW & 0x0f )
);
printf( "Low\n" );
sleep( 1
);
/* Output a byte of highs to the data lines
*/
out8( data_handle, HIGH );
out8(
ctrl_handle, (HIGH & 0x0f ));
printf( "High\n"
);
sleep( 1
);
}
return
0;
}
QNX LPT Port Programming
时间: 2024-10-26 21:57:14
QNX LPT Port Programming的相关文章
Serial Port Programming on Linux(转载)
This is a tutorial on how to program the Serial Ports on your Linux box.Serial Ports are nice little interfaces on the PC which helps you to interface your embedded system projects using a minimum number of wires.In this tutorial we will write a smal
Serial Port Programming using Win32 API(转载)
In this tutorial we will learn How to communicate with an external device like a microcontroller board or modem using the Serial port of a windows PC(Windows XP,7). The software is written using C language and communicates with the Serial Port using
Windows Serial Port Programming in C.
Similar with the linux version, this article would demonstrate how to write a simple windows . I divide the 2 operations : write and read into 2 threads. Of course, one could call ReadFile and WriteFile (those are mapping to read/wrrite function in l
C#调用斑马打印机打印条码标签(支持COM、LPT、USB、TCP连接方式和ZPL、EPL、CPCL指令)
在批量打印商品标签时一般都要加上条码或图片,而这类应用大多是使用斑马打印机,所以我也遇到了怎么打印的问题. 一种办法是用标签设计软件做好模板,在标签设计软件中打印,这种办法不用写代码,但对我来说觉得不能接受,所以尝试代码解决问题. 网上搜索一番,找不到什么资料,基本都是说发送ZPL.EPL指令到打印机,而且还是COM/LPT口连接打印机.后来研究.net的打印类库,发现是用绘图方式打印至打印机的,也叫GDI打印,于是思路有了点突破,那我可以用报表工具画好标签,运行报表时,把结果输出位图,再发送至
windows 远程桌面研究
最近因为一个监控相关的项目,深入研究了一下 windows 的 远程桌面的相关知识. 1. 如何让关闭了远程桌面连接的用户,对应的 session 立即退出 windows server. 大家使用 mstsc.exe 远程桌面登录windows server时,退出时,99.99%的人会直接关闭 mstsc.exe 窗口,而不会点击开始--->退出.导致的问题是,登录用户已经提出了,但是 query user 和 query session 时,发现退出的用户,在 windows server
Python windows serial
Python windows serial 一.参考文章: Serial port programming http://www.cnblogs.com/2zhyi/p/3405339.html python pyserial 2.7 https://pypi.python.org/pypi/pyserial 串口通讯的python模块——pySerial http://blog.csdn.net/dainiao01/article/details/5885122 Welcome to pySe
C# ZPL II 命令打印标签
public class BarPrinter { public static byte[] ZPLPrinter(string p_title = "", string p_specs = "", string p_date = "", string p_code = "") { try { #region ZPL II 打印指令 string title = p_title, specs = p_specs, date =
BIOS设置图解教程-看完就没有不明白的了
BIOS(基本输入/输出系统)是被固化在计算机CMOS RAM芯片中的一组程序,为计算机提供最初的.最直接的硬件控制.BIOS主要有两类∶AWARD BIOS和AMI BIOS.正确设置BIOS可大大提高系统性能. 第一部分.AWARD BIOS设置 一.进入 BIOS 设置 电脑刚启动,出现如下图1画面时. 图1 当出现图1画面时,按下Delete(或者Del)键不放手直到进入BIOS(基本输入/输出系统)设置,如下图2 图2(主菜单) 上图是AWARD BIOS设置的主菜单.最顶一行标出了S
linux 内核协助的探测
Linux 内核提供了一个低级设施来探测中断号. 它只为非共享中断, 但是大部分能够在共 享中断状态工作的硬件提供了更好的方法来尽量发现配置的中断号.这个设施包括 2 个函 数, 在<linux/interrupt.h> 中声明( 也描述了探测机制 ). unsigned long probe_irq_on(void); 这个函数返回一个未安排的中断的位掩码. 驱动必须保留返回的位掩码, 并且在后 面传递给 probe_irq_off. 在这个调用之后, 驱动应当安排它的设备产生至少一次 中断