[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

c++  VS.  python:   hardware control.

Posted on 2007-07-20
3
Medium Priority
?
1,212 Views
Last Modified: 2013-12-27
my electronics class almost touched using computer to control hardware, but we ran out of time.   it was to be powered by and controlled through a COM port (like the old mouse port, remember?)  and DC motors and lights could be operated through that.


my question is though, the python.org headline picture shows a lot of electronics and stuff, I am wondering though,  is c++ better at controlling "simple"  stuff like DC motors , or maybe today python can do some of those as well?


I'd love to initiate hardware controls from python than c++ ( and i don't care if I am not as powerful, it's just easier to learn)



I guess my question is actually, how to start hardware stuff with python, or rather, how to start hardware design.
0
Comment
Question by:Troudeloup
3 Comments
 
LVL 30

Expert Comment

by:IanTh
ID: 19537676
python has no access to hardware
c and c++ can thats why a lot of apps are written in c
0
 
LVL 15

Expert Comment

by:mish33
ID: 19538864
You can do whatever you want from python.

True you don't control memory addresses in python, but (a) usually it's not needed as you have hardware control through devices like COM-port which are easily accessible via file interface and
(b) python 2.5 has direct native dll access (ctypes module) which allow you access anything (ctypes is also available for earlier version of python).

In your case it should be extremely easy: type some char to COM to start/stop the motor.
0
 
LVL 4

Accepted Solution

by:
doraemon-nolife earned 2000 total points
ID: 19562766
Python cant do the control on hardware directly.

However, you can call python from C program or call C program from python program. It is some sort like JNI in java.

Check these link, it might be useful to you.

Extending and Embedding python interpreter
http://docs.python.org/ext/ext.html

Python/C API
http://docs.python.org/api/api.html

:) Good Luck
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
The viewer will learn how to implement Singleton Design Pattern in Java.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question