问题描述
我想在不使用串行
协议的情况下写入RS232的引脚。使用将是每个引脚都可以用来完成定制硬件中的电路
。我可以使用python串行通信
a BASIC邮票或Javelin邮票,然后使用邮票设置
许多引脚为0'或1'但是对于python来说应该是那么难吗。
我已经看过python如何与serial串行连接模块但是
它只使用Java的javax.comm库。无论如何都要将极低级别的设备写入COM端口吗?
总结我正在寻找类似的东西:
ser = serial.Serial(0)
ser.pin0 = 1
ser.pin1 = 1
ser.pin2 = 1
.....
或
ser.write('''0xFF'')
哪个会将RS232电缆上的8个引脚设置为1'的
这真的不是Python问题 - 它是低 - 硬件问题。
然而,简短的回答是,由于种种原因,几乎肯定不可能像你想要的那样。连接器上的输出引脚由某种串行硬件驱动程序直接驱动,
和硬件几乎肯定不会暴露出一个接口,让
你做你想做的事。
我想你想要做的就是看着使用并行端口
(通常称为PC上的打印机端口)。但无论如何,
的答案如何使并行端口执行此操作?是一个低级硬件问题,而不是Python问题。
正如Roy所说,你实际上不可能在PC做这个
。我只是想说明你误解了pyserial中Java内容的存在。如果你在Jython下运行,那么使用
的东西,但如果你在Windows上使用win32serial.py文件(或者
那样的东西...... 。将通过记忆)将使用,而不是
java one。
此外,pyparallel应该让你更接近你想要的东西,并且事实上
关于使用它的问题肯定是关于主题的,尽管
故障排除硬件问题可能不是。
- Peter
此级别的访问硬件几乎总是被管理通过某种形式
的任何实际操作系统中的设备驱动程序。甚至Microsoft Windows
都有串行和并行端口的设备驱动程序。这不是你的b / b
父亲的MS-DOS了。允许用户在硬件级别直接访问是一种安全漏洞。
此外,如果您希望运行除IBM以外的任何其他应用程序-PC克隆,然后
硬件会有所不同。即使是运行x86处理器的系统像NEC PC-98那样的b $ b也有8255个并行接口,但它们位于机器中不同端口上的
。
I want to write to the pins of an RS232 without using the serial
protocol. The use would be every pin could act to complete a circuit
in customized hardware. I could use python to communicate serially to
a BASIC stamp or a Javelin stamp and then use the stamp to set however
many pins as 0''s or 1''s but should it be that hard to do with python.
I''ve looked through how python does serial with the "serial" module but
it just uses Java''s javax.comm libraries. Is there anyway to do very
low level device writing to COM ports?
In summary I''m looking for something like:
ser = serial.Serial(0)
ser.pin0 = 1
ser.pin1 = 1
ser.pin2 = 1
.....
or
ser.write(''0xFF'')
which would set 8 pins on the RS232 cable to 1''s
This really isn''t a Python question -- it''s a low-level hardware question.
The short answer, however, is that it''s almost certainly impossible to
anything like what you want, for a number of reasons. The output pins on
the connector are driven directly by some sort of serial hardware driver,
and the hardware almost certainly doesn''t expose an interface which lets
you do what you''re after.
I think want you want to be doing is looking at using a parallel port
(commonly called a printer port on PC''s). But in any case, the answer to
"How do I make the parallel port do this?" is a low-level hardware
question, not a Python question.
As Roy indicates, you can''t practically make a serial port on a PC do
this. I just wanted to note that you''ve misunderstood the presence of
the Java stuff in pyserial. If you''re running under Jython then that
stuff is used, but if you''re on Windows the file win32serial.py (or
something like that... going by memory) is what will be used, not the
java one.
Also, pyparallel should let you get closer to what you want, and in fact
questions about using it are certainly on-topic here, though
troubleshooting hardware issues are probably not.
-Peter
Accessing hardware at this level is almost always managed by some form
of device driver in any real operating system. Even Microsoft Windows
has device drivers for serial and parallel ports. This is not your
father''s MS-DOS any more. It would be a security breach to allow user
applications direct access at the hardware level.
Also, if you ever hope to run on anything except an IBM-PC clone, then
the hardware will be different. Even systems that run x86 processors
like the NEC PC-98 have 8255 parallel interfaces, but they are located
on different ports in the machine.
这篇关于将引脚写入RS232的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!