使用C来使用串行和并行端口 [英] use of serial and parrallel port using C

查看:85
本文介绍了使用C来使用串行和并行端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我可以使用哪种命令来控制我的电脑的串口和并口。

我的电脑。我想用我的笔记本电脑代替微控制器,用ANSI C编写我的

软件,用于传感器和其他电子设备的控制目的。


我现在还没有做过任何一次C,所以我想我的知识就是现在初学者的



感谢所提供的任何帮助。


Naveed

Hi All,

What kind of commands can I use to control the serial and parallel port of
my pc. I want to use my laptop instead of microcontrollers and write my
software in ANSI C to be used for control purposes of sensors and other
electronic devices.

I haven''t done any C for a while now so I would assume my knowledge is that
of a beginner now.

A thousand thanks for any help offered or intended.

Naveed

推荐答案

" The Man随着口琴 <共**************** @ yahoo.co.uk>写在

新闻:cf ********** @ rdel.co.uk:
"The Man With The Harmonica" <co****************@yahoo.co.uk> wrote in
news:cf**********@rdel.co.uk:
大家好,

我可以用什么样的命令来控制我的电脑的串行和并行端口。
Hi All,

What kind of commands can I use to control the serial and parallel port
of my pc.




无。 ISO C没有任何命令,也不知道有关

串行或并行端口的任何信息。您需要在新闻组中询问这个

您正在使用的平台的程序,例如: DOS,Linux,Win32等


-

- 马克 - >

-



None. ISO C doesn''t have any commands nor does it know anything about
serial or parrallel ports. You''ll need to ask this in a newsgroup that
programs for the platform you are using, e.g. DOS, Linux, Win32, etc.

--
- Mark ->
--


The Harmon With The Harmonica写道:
The Man With The Harmonica wrote:
大家好,

我可以使用哪种命令来控制我的电脑的串口和并口。我想用我的笔记本电脑代替微控制器,用ANSI C编写我的
软件,用于传感器和其他电子设备的控制目的。

我没有现在已经做了一段时间了,所以我现在认为我的知识就是现在的初学者。

非常感谢你提供的任何帮助。

Naveed
Hi All,

What kind of commands can I use to control the serial and parallel port of
my pc. I want to use my laptop instead of microcontrollers and write my
software in ANSI C to be used for control purposes of sensors and other
electronic devices.

I haven''t done any C for a while now so I would assume my knowledge is that
of a beginner now.

A thousand thanks for any help offered or intended.

Naveed




news:comp.arch.embedded


可以使用ANSI C访问串口和并行端口

以及其他设备,只要这些设备是内存

映射。无论操作系统是否存在,都允许

这是一个不同的问题。


但是,这段代码是特定于平台的而不是便携式的/>
到没有相同内存映射的平台。


技术是通过解除引用

指针来访问硬件设备。例如,可以使用设备地址的值分配指向整数

的指针:

volatile unsigned char * Serial_Receive_Register =

(volatile unsigned char *)0x40000;


unsigned char Read_Serial_Port(void)

{

return * Serial_Receive_Register;

}


在阅读接收寄存器之前,应该首先检查

状态,还有一个设计来处理

没有收到任何内容。


-

Thomas Matthews


C ++新闻组欢迎辞:
http://www.slack.net/ ~shiva / welcome.txt

C ++常见问题: http://www.parashift.com/c++-faq-lite

C常见问题: ht tp://www.eskimo.com/~scs/c-faq/top.html

alt.comp.lang.learn.c-c ++ faq:
< a rel =nofollowhref =http://www.comeaucomputing.com/learn/faq/target =_ blank> http://www.comeaucomputing.com/learn/faq/

其他网站:
http://www.josuttis.com - C ++ STL图书馆书



news:comp.arch.embedded

One can use ANSI C to access serial ports and parallel ports
as well as other devices as long as those devices are memory
mapped. Whether the operating system, if there is one, allows
this is a different issue.

However, this code would be platform specific and not portable
to platforms that do not have the same memory mapping.

The technique is to access the hardware devices by dereferencing
pointers. For example, one would assign a pointer to an integer
with the value of the device''s address:
volatile unsigned char * Serial_Receive_Register =
(volatile unsigned char *) 0x40000;

unsigned char Read_Serial_Port(void)
{
return * Serial_Receive_Register;
}

Before reading the receive register, one should check that
the status first and also have a design to handle when
nothing has been received.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book


#我可以用什么样的命令来控制串口和并口?

#我的电脑。我想用我的笔记本电脑代替微控制器,用ANSI C编写我的

#软件,用于传感器和其他电子设备的控制目的。


部分取决于操作系统是否为那些可以打开的设备提供文件名。例如,在unices上,您可以打开

串口,文件名如/ dev / ttyS0。


-

SM Ryan http://www.rawbw.com/~wyrmwif/

全世界都在反对我们。
# What kind of commands can I use to control the serial and parallel port of
# my pc. I want to use my laptop instead of microcontrollers and write my
# software in ANSI C to be used for control purposes of sensors and other
# electronic devices.

Depends in part on whether the operating system provides file names for
those devices that you can fopen. For example on unices, you can open
serial ports with file names like "/dev/ttyS0".

--
SM Ryan http://www.rawbw.com/~wyrmwif/
The whole world''s against us.


这篇关于使用C来使用串行和并行端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆