I'm using python to try and talk to my Arduino with pyserial. The code should wait for an input from COM5, (the arduino), and then sends a 1 and waits for the response. import serial connected = False ser = serial.serial("COM5", 9600) while not connected: serin = ser.read() connected = True ser.write("1") while ser.read() == '1': ser.read() ser.close() All I get if this error message. Traceback (most recent call last): File "C:\Users\Patrick\Documents\Python\serial.py", line 2, in <module> import serial File "C:\Users\Patrick\Documents\Python\serial.py", line 10, in <module> ser = serial.serial("COM5", 9600) TypeError: 'module' object is not callable

Member Avatar
Member Avatar
+0 forum 8

import serial import threading import Queue import Tkinter as tk class SerialThread(threading.Thread): def __init__(self, queue): threading.Thread.__init__(self) self.queue = queue def run(self): s = serial.Serial('COM10',9600) while True: if s.inWaiting(): text = s.readline(s.inWaiting()) self.queue.put(text) class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.geometry("1360x750") frameLabel = tk.Frame(self, padx=40, pady =40) self.text = tk.Text(frameLabel, wrap='word', font='TimesNewRoman 37', bg=self.cget('bg'), relief='flat') frameLabel.pack() self.text.pack() self.queue = Queue.Queue() thread = SerialThread(self.queue) thread.start() self.process_serial() def process_serial(self): self.text.delete(1.0, 'end') while self.queue.qsize(): try: self.text.insert('end', self.queue.get()) except Queue.Empty: pass self.after(100, self.process_serial) app = App() app.mainloop() This code is to receive serial data from one pc and to print on tkinter window of other pc.The data …

Member Avatar
Member Avatar
+0 forum 1

Hi guys, What i need is a way to [B]check the available USB ports in windows[/B] using python. The purpose: I'm trying to run on startUp a script that wait to plug in my Token, and after that the script will log me in automatically into the system that I'm using. Scenario: 1) Waiting the special port to be used. 2) When detect some device in it - starting the application. 3) Auto log in with the Credentials that are on the token. I think this should be the easiest way to make this work... Please give some example of …

Member Avatar
Member Avatar
+0 forum 4

Before going into the problem, here is some hardware/software information: Device accessed: Ohaus Scout Pro Digital Weight Machine ([url="http://www.northshorecare.com/ohaus-scout-pro.html"]product link[/url]) Interface used: USB ([url="http://www.carolina.com/product/702448.do?s_cid=ppc_gl_products"]product link[/url]) Serial Port: COM3 OS: WinXP Python Version: Activestate Python 2.7 pyserial version: 2.5 Python recognized this serial port and had no problems opening it. I am new to python as well as pyserial. I couldn't figure out how exactly can I read data from the serial port. I used the following code: [code]import serial ser=serial.Serial(port='COM3',timeout=3) s=ser.read(100) #reading up to 100 bytes print s[/code] This prints nothing. During those 3 seconds timeout, I placed an object …

Member Avatar
+0 forum 0

Hi, I can connect to an energy-meter (Baudrate 300!) and the logfile with 228 lines comes slowly in.[code=Python]line = ser.readline(eol='!') print line [/code] If I use the above code, the complete logfiles is shown. And if I parse separatly saved logfiles with match, it sorts out the right values into sqlite. So both "parts" work separatly. But my script is not capable of handing over the output to parse it. It does'nt throw an error, only that 0 values were given. What am I missing? First I thought, the script is to fast for the slow input (takes over a …

Member Avatar
+0 forum 0

I used [URL="http://www.parallax.com/Store/Education/KitsandBoards/tabid/182/CategoryID/67/List/0/SortField/0/Level/a/ProductID/313/Default.aspx"]Parallax's Basic Stamp Homework Board[/URL] and an [URL="http://www.radioshack.com/product/index.jsp?productId=2909788"]accelerometer[/URL] to use as a mouse. It works better than I thought it would. [URL="http://sourceforge.net/projects/pyserial/"]PySerial[/URL] is used to grab the debugged values from the stamp. The circuit is compiled of two push buttons, 2 LEDs to tell when a button is pushed, and the accelerometer. The chip is coded in BASIC: Where IN9, IN10 are the push buttons and X on pin 8, Y on pin 7, and are read by pulse rate. [CODE] ' {$STAMP BS2} ' {$PBASIC 2.5} x VAR Word y VAR Word DO PULSIN 8, 1, x …

Member Avatar
+0 forum 0

The End.