473,729 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending bytes to parallel port

hello people.

i've been trying to send an 8 byte string to my parallel port under
freebsd. the purpose is it to control a relay board.
the board simply responds to the output byte coming from the port. eg.
00000001 will set pin 1 high and flick the relay open.
todate i've attempted this with merely open() on /dev/ppi0 and numpy for
the byte array, but i just can't seem to get it working.
i know the parallel port works and i know the relay board works (tested
it with it's own windows ultility) so it's just my crappy programming
keeping me from success.
Jul 28 '06 #1
11 5278
On 2006-07-28, Timothy Smith <ti*****@open-networks.netwro te:
i've been trying to send an 8 byte string to my parallel port
under freebsd. the purpose is it to control a relay board. the
board simply responds to the output byte coming from the port.
eg. 00000001 will set pin 1 high and flick the relay open.
todate i've attempted this with merely open() on /dev/ppi0 and
numpy for the byte array, but i just can't seem to get it
working. i know the parallel port works and i know the relay
board works (tested it with it's own windows ultility) so it's
just my crappy programming keeping me from success.
I'm guessing there's an implied request for help there
somewhere. This would be a good start:

http://www.google.com/search?q=python+parallel+port

I'd particularly recommend taking a look at the pyparallel
module found here:

http://pyserial.sourceforge.net/

I've not used pyparallel, but based on my experience with
pyserial and some of Chris Liechti's other work, I'd bet
dollars to doughnuts it's your best option.

--
Grant Edwards grante Yow! It's so OBVIOUS!!
at
visi.com
Jul 29 '06 #2
On 2006-07-29, Grant Edwards <gr****@visi.co mwrote:
I'd particularly recommend taking a look at the pyparallel
module found here:

http://pyserial.sourceforge.net/
Oops, there isn't actually a link to pyparallel from that page
(I swear there used to be). Here's the pyparallel page:

http://pyserial.sourceforge.net/pyparallel.html

--
Grant Edwards grante Yow! Here we are in
at America... when do we
visi.com collect unemployment?
Jul 29 '06 #3
Grant Edwards wrote:
On 2006-07-28, Timothy Smith <ti*****@open-networks.netwro te:

>i've been trying to send an 8 byte string to my parallel port
under freebsd. the purpose is it to control a relay board. the
board simply responds to the output byte coming from the port.
eg. 00000001 will set pin 1 high and flick the relay open.
todate i've attempted this with merely open() on /dev/ppi0 and
numpy for the byte array, but i just can't seem to get it
working. i know the parallel port works and i know the relay
board works (tested it with it's own windows ultility) so it's
just my crappy programming keeping me from success.

I'm guessing there's an implied request for help there
somewhere. This would be a good start:

http://www.google.com/search?q=python+parallel+port

I'd particularly recommend taking a look at the pyparallel
module found here:

http://pyserial.sourceforge.net/

I've not used pyparallel, but based on my experience with
pyserial and some of Chris Liechti's other work, I'd bet
dollars to doughnuts it's your best option.

yes, i did try pyparallel however it will not install on freebsd,
setup.py errors.

and yes i've done quite a bit of googling, i never expected it to be
this difficult. i've done work with serial ports before. never parallel but.
Jul 29 '06 #4
Grant Edwards wrote:
On 2006-07-29, Grant Edwards <gr****@visi.co mwrote:

>I'd particularly recommend taking a look at the pyparallel
module found here:

http://pyserial.sourceforge.net/

Oops, there isn't actually a link to pyparallel from that page
(I swear there used to be). Here's the pyparallel page:

http://pyserial.sourceforge.net/pyparallel.html

i've had people suggest using fcntl to set the pins status, i'm looking
to that if anyone has any suggestions
Jul 29 '06 #5
Dennis Lee Bieber wrote:
On Sat, 29 Jul 2006 13:59:02 +1000, Timothy Smith
<ti*****@open-networks.netdec laimed the following in comp.lang.pytho n:

>and yes i've done quite a bit of googling, i never expected it to be
this difficult. i've done work with serial ports before. never parallel but.

Parallel gets ugly -- there are something like three different types
of parallel port hardware, and they behave slightly differently (status
bits, bidirectionalit y, etc.).

http://www.amazon.com/gp/product/096...lance&n=283155

is MS-DOS/Windows biased, but may give hints...
(a few years ago I had to program a W98 laptop to write 6 data pins --
representing three rs-422 style balanced signals -- in response to a
1KHz clock signal coming in on another pin... I had it working, but
couldn't get rid of every last W98 OS interrupt, such that I had a 1-3
clock length skip about every 700 clocks)
i think fcntl is what i'm after, although i've never done any system
level stuff like this before so it's a learning curve for me.
right now i'm attempting to use it like so and getting the following error.
>>fd = open('/dev/ppi0','w')
fcntl.ioctl(f d.fileno(),'PPI SCTRL',10000000 )
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: an integer is required

i guess i'm failing to properly define the int i need for the 8byte
value ineed to send the port to set pins high /low
Jul 29 '06 #6
>
>>fd = open('/dev/ppi0','w')
>>fcntl.ioctl(f d.fileno(),'PPI SCTRL',10000000 )
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: an integer is required

i guess i'm failing to properly define the int i need for the 8byte
value ineed to send the port to set pins high /low
Python doesn't know about PPISCTRL - it has no way of knowing all
"secret", OS-specific constants for ioctl-calls.

So, you need to figure out the numeric value of that constant .- look it
up in the appropriate header-file.

Then, you do have the next problem with passing that 10000000 value of
yours. ioctl expects strings or buffers as parameters which contain a
byte-representation of the value you want to set. This is an snippet I
use to read the event device capabilities under linnux:
buf = array.array('c' , [' ' for i in xrange(EV_MAX / 8 + 1)])
fcntl.ioctl(sel f._fd, EVIOCGBIT(0, len(buf)), buf, True)
caps = struct.unpack(" I", buf)[0]

HTH,

Diez
Jul 29 '06 #7
Diez B. Roggisch wrote:
> >>fd = open('/dev/ppi0','w')
fcntl.ioctl(f d.fileno(),'PPI SCTRL',10000000 )
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: an integer is required

i guess i'm failing to properly define the int i need for the 8byte
value ineed to send the port to set pins high /low

Python doesn't know about PPISCTRL - it has no way of knowing all
"secret", OS-specific constants for ioctl-calls.

So, you need to figure out the numeric value of that constant .- look it
up in the appropriate header-file.

Then, you do have the next problem with passing that 10000000 value of
yours. ioctl expects strings or buffers as parameters which contain a
byte-representation of the value you want to set. This is an snippet I
use to read the event device capabilities under linnux:
buf = array.array('c' , [' ' for i in xrange(EV_MAX / 8 + 1)])
fcntl.ioctl(sel f._fd, EVIOCGBIT(0, len(buf)), buf, True)
caps = struct.unpack(" I", buf)[0]

HTH,

Diez
*sigh*
if only pyparallel would install

Jul 29 '06 #8
*sigh*
if only pyparallel would install
*sigh* If only you said _what_ failed we could maybe help you make it
work... :)

Diez
Jul 29 '06 #9
Diez B. Roggisch wrote:
>*sigh*
if only pyparallel would install

*sigh* If only you said _what_ failed we could maybe help you make it
work... :)

Diez
titan# python setup.py install
running install
running build
running build_py
Traceback (most recent call last):
File "setup.py", line 19, in ?
package_data = data_files
File "/usr/local/lib/python2.4/distutils/core.py", line 149, in setup
dist.run_comman ds()
File "/usr/local/lib/python2.4/distutils/dist.py", line 946, in
run_commands
self.run_comman d(cmd)
File "/usr/local/lib/python2.4/distutils/dist.py", line 966, in
run_command
cmd_obj.run()
File "/usr/local/lib/python2.4/distutils/command/install.py", line
506, in run
self.run_comman d('build')
File "/usr/local/lib/python2.4/distutils/cmd.py", line 333, in run_command
self.distributi on.run_command( command)
File "/usr/local/lib/python2.4/distutils/dist.py", line 966, in
run_command
cmd_obj.run()
File "/usr/local/lib/python2.4/distutils/command/build.py", line 112,
in run
self.run_comman d(cmd_name)
File "/usr/local/lib/python2.4/distutils/cmd.py", line 333, in run_command
self.distributi on.run_command( command)
File "/usr/local/lib/python2.4/distutils/dist.py", line 965, in
run_command
cmd_obj.ensure_ finalized()
File "/usr/local/lib/python2.4/distutils/cmd.py", line 117, in
ensure_finalize d
self.finalize_o ptions()
File "/usr/local/lib/python2.4/distutils/command/build_py.py", line
60, in finalize_option s
self.data_files = self.get_data_f iles()
File "/usr/local/lib/python2.4/distutils/command/build_py.py", line
120, in get_data_files
filenames = [
File "/usr/local/lib/python2.4/distutils/command/build_py.py", line
128, in find_data_files
globs = (self.package_d ata.get('', [])
AttributeError: 'NoneType' object has no attribute 'get'
titan#

Jul 29 '06 #10

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

Similar topics

1
14528
by: coder_1024 | last post by:
I'm trying to send a packet of binary data to a UDP server. If I send a text string, it works fine. If I attempt to send binary data, it sends a UDP packet with 0 bytes of data (just the headers). I can see this because I'm running Ethereal and watching the packets. I'm defining the packets as shown below: $text_msg = "Hello, world\r\n"; $binary_msg = chr(0x01).chr(0x02).chr(0x03).chr(0x00).chr(0xA0); $binary_msg_size = 5;
1
16707
by: Chuck Rittersdorf | last post by:
Hi There I am having a problem using the win32 API from VB6. I am trying to send a command string to a printer(zebra TLP 2742) on LPT1 using the folowing API functions CreateFile and WriteFile I have written C code which works fine, just the VB translation/port
4
3577
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 printer port. I've tried to help myself with this one but searching in the "Python Library Reference" that installed with my version, yielded nothing on the subject of either timing or parallel port.
9
8437
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 port ie to send data and to read the state of the parallel port including the control lines. Can anyone help/point me in the correct direction? I have tried the help files and the internet but am unable to find anything relevant. Thanks in...
12
8626
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 pins. Any Java people know a good solution? I'm trying to use JNI and create my own library, but building the library gives me these errors: ld: warning: cannot find entry symbol _start; defaulting to 0000000008048094 ParallelPort.o: In...
7
2685
by: D. Patrick | last post by:
I need to duplicate the functionality of a java applet, and how it connects to a remote server. But, I don't have the protocol information or the java source code which was written years ago. So, I used a packet sniffer and saw the protocol (TCP), the port, IP address, etc. All is good. I tried 2 different versions of .NET code to duplicate the requests to the remote server. Again, I used the packet sniffer and my packets seemed...
4
3284
by: Hector M Banda | last post by:
Hi all, How can I send chr(7) thru VB2005 using the parallel port? BTW This is for a POS system. Thanks, -hb
2
4456
by: hari | last post by:
Hi all, I need to automate printer command testing, prinetr supports parallel/ serial/USB.How can i send the commands from python to printer. I have got pyparallel, as am new to python, no idea how to work on it. Please give some tips,The comamnd to be sent to the printer is hex data "1B 40".please give a example,it will be grateful.
4
15351
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 using PyParallel, but the USB->Parallel converter doesn't actually map to the LPT port .. and PyParallel only looks for LPT ports? Has anyone tried doing this? What are my options for controlling parallel connections on a laptop with no parallel...
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.