473,756 Members | 7,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing Windows Serial Port

I need to access the serial port via python on a windows machine.
Reading on the web, there are three solutions: pyserial, siomodule and
USPP. pyserial seems to be the best option since the other two are
tested with Windows 95 and older versions of python. Would you agree
with this or have I missed an option?

Can anyone provide me an example of how to access the serial port with
pyserial?

Thanks
George T.

Feb 6 '06 #1
5 24970
George T. schreef:
I need to access the serial port via python on a windows machine.
Reading on the web, there are three solutions: pyserial, siomodule and
USPP. pyserial seems to be the best option since the other two are
tested with Windows 95 and older versions of python. Would you agree
with this or have I missed an option?
I hadn't even heard of siomodule and USPP; pyserial is what I use when I
need to read/write from/to the serial port.
Can anyone provide me an example of how to access the serial port with
pyserial?


It's quite simple; there are a number of examples on pyserial's website.
Here's a small quick and dirty script that reads data from a serial port
and broadcasts it as UDP over the network to make the incoming data
available to other computers in the office:

import socket
import sys

import serial

ser = serial.Serial(' COM1', 38400, timeout=1)
sock = socket.socket(s ocket.AF_INET, socket.SOCK_DGR AM)
sock.setsockopt (socket.SOL_SOC KET, socket.SO_BROAD CAST, 1)
while True:
msg = ser.readline()
sock.sendto(msg , ('<broadcast>', 5000))
sys.stdout.writ e(msg)
Basically you can use the objects like other file-like objects.
--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton

Roel Schroeven
Feb 6 '06 #2
On 2006-02-06, George T. <ge***********@ yahoo.com> wrote:
I need to access the serial port via python on a windows machine.
Reading on the web, there are three solutions: pyserial, siomodule and
USPP.
You can also just use win32 stuff directly (CreateFile et al).
pyserial seems to be the best option since the other two are
tested with Windows 95 and older versions of python. Would you agree
with this or have I missed an option?
I've used PySerial and win32 system calls. I've never used the
other two. Try pyserial first. If you need lower level
control than that gives you, use win32 calls.
Can anyone provide me an example of how to access the serial port with
pyserial?


http://pyserial.sourceforge.net/

--
Grant Edwards grante Yow! Is this "BOOZE"?
at
visi.com
Feb 6 '06 #3
Hi All,
Would anybody know whether PySerial would work over an usb/serial
adapter?
(what about usb/parallel adapters?)
Thx.
malv

Feb 7 '06 #4
malv schreef:
Hi All,
Would anybody know whether PySerial would work over an usb/serial
adapter?
If the driver for the adapter creates a virtual COM-port (i.e. it shows
up as a serial port in Windows' device manager), it works. The software
sees no difference between a real port and a fake one.
(what about usb/parallel adapters?)


Never tried it, but I guess it will work too.

--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton

Roel Schroeven
Feb 7 '06 #5
On 2006-02-07, malv <ma*****@telene t.be> wrote:
Hi All,
Would anybody know whether PySerial would work over an usb/serial
adapter?
Yes.
(what about usb/parallel adapters?)


Don't know.

--
Grant Edwards grante Yow! I'm an East Side
at TYPE...
visi.com
Feb 7 '06 #6

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

Similar topics

4
9094
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the same port to change the direction of the robot. The trajectory frame is managed by an applet, and the project works good when the applet is called by a html document allocated in the same local machine under W98 where the classes and the serial port...
2
8810
by: fdunne2 | last post by:
Hi, I need to interface a signal generator with my computer's serial port ( to set the frequency, level etc using the appropriate byte codes). How can I send and receive (acknowledge the message sent - successful/unsuccessful) data throught the serial port (RS232) in MFC? Some sample code would be most appreciated! Regards, F.
6
14020
by: Jeff | last post by:
Hello, Someone can help me about serial port with C++ .NET (Windows forms application). Like setting port, opening it, transmiting, receiving, closing, etc. Thanks very much (for me and my students)
13
4833
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have been told it is not possible to access the serial ports from asp.net. The application is used to control custom hardware. The hardware is connected to a PC through serial ports. Our customer wants to control the hardware from a remote...
1
10919
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o errors 2) My Nokia 6600 prompted me the message "Accept Connection request from DEMON?" note: DEMON is my computers name. 3) Using my Nokia 6600, I hit the button that refers to the "Yes"
38
9661
by: shussai2 | last post by:
Hi, I am trying to access Serial Port in XP. I am using Dev-C++ IDE that uses Mingw as a compiler. I just want to know how I can open up serial port on COM1 and write some data. I have searched quite a bit over the web and could not find anything useful. I don't want to use Visual C++ or Cygwin, linux, etc. If any of you guys have some little tid bit of code that would be great to look at.
3
11631
by: naveen.sabapathy | last post by:
Hi, I am trying to use virtual serial ports to develop/test my serial communication program. Running in to trouble... I am using com0com to create the virtual ports. The virtual ports seem to be working fine when I test it with Hyperterminal . I am using the example program that comes with pyserial, as below. --------------- import serial
0
1551
by: satheeshviswanathan | last post by:
Hi, I am new to visual c#/.NET. Can anyone help me in accessing a virtual serial port(COM port) in a c#/.NET windows application.I have a s/w for virtual serial port. I need to connect two COM ports and record the communication in a text file. Thanks in advance Satheesh.
2
3153
by: Bassem | last post by:
I'm working on simple chat program via serial port. It works fine, but i face this problem. When i try to open the exe, UnauthorizedAccess exception occurs, i can't use COM1 becuase someone else has it. I checked it and found that another copy of the program still work (by task manager). That's mean closing the program will not close the serial port. I tried these : Note: I read it using a separate thread. 1)override OnClose to, close the...
0
9384
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
9212
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9973
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9790
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...
0
8645
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...
1
7186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6473
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();...
1
3742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2612
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.