FW: Comunicating through COM ports

Alves, Carlos Alberto - Coelce calves at coelce.com.br
Fri Dec 21 09:17:47 EST 2001


Thanks for the example. But, where can I find such module Serial?!

-----Original Message-----
From: David Mallwitz [mailto:dmallwitz at cox.rr.com] 
Sent: Thursday, December 20, 2001 10:26 PM
To: python-list at python.org
Subject: Re: Comunicating through COM ports


Comunicating through COM portsChapter 19 of Mark Hammond and Andy Robinson's
'Python Programmingon on Win32' covers this quit well, and with the
Activestate Python distro there is a multithreaded demo called
'win32comport_demo.py'. But here's what I do - example is from a console
connection to an old Cisco router.

>>> from Serial import Serial
>>> ### open the COM1 port
>>> serialconfig = Serial.PortDict()
>>> serialconfig['port'] = Serial.COM1
>>> serialconfig['rxBufSize'] = 4096
>>> port = Serial.Port(serialconfig)
>>> port.open()
>>> port.write('show conf \r')
>>> x = port.read()
>>> x
'show conf \r\nUsing 768 out of 32762 bytes\r\n!\r\nversion 11.1\r\nno
service u
dp-small-servers\r\nno service tcp-small-servers\r\n!\r\nhostname
Router\r\n!\r\
n!\r\nip subnet-zero\r\nno ip domain-lookup\r\n!\r\nhub ether 0 1\r\n
link-test\
r\n auto-polarity\r\n!\r\nhub ether 0 2\r\n link-test\r\n
auto-polarity\r\n!\r\n
hub ether 0 3\r\n link-test\r\n auto-polarity\r\n --More-- '

Best,
Dave


"Alves, Carlos Alberto - Coelce" <calves at coelce.com.br> wrote in message
news:mailman.1008852145.28654.python-list at python.org...
Anybody could give me an example code of how connect/comunicate through COM
ports (i.e. COM1, COM2). I'm under windows 98.
Thanks!!!
Carlos Alberto
COELCE/DPRON-Departamento de Projetos e Obras Norte
Fone: 677- 2228
e-mail: calves at coelce.com.br
\|||/
(o o)
--ooo0-(_)-0ooo--




-----=  Posted via Newsfeeds.Com, Uncensored Usenet News  =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
 Check out our new Unlimited Server. No Download or Time Limits!
-----==  Over 80,000 Newsgroups - 19 Different Servers!  ==-----
-- 
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20011221/6117ab3d/attachment.html>


More information about the Python-list mailing list