Read Data over Serial From PC
Posted: Wed Mar 08, 2017 9:17 pm
Well ,
After hours and hours trying to make my Macbook Send Simple String data to my pyboard v1.1 . l ask aid here ... let me explaind in details so :
L wrote the following python program onto main.py
# main.py -- put your code here!
from pyb import UART
import os
uart = UART(1, 9600)
#uart.init(9600, bits=8, parity=None, stop=1)
#if (os.isfile('data.txt')):
#if (isfile('data.txt')):
# print('data.txt')
# f = open('data.txt', 'r')
# f2 = open('dcopy.txt', 'w')
# f2.write(f.read())
# f2.close()
#else:
try:
f = open('data.txt', 'r')
f2 = open('dcopy.txt', 'w')
f2.write(f.read())
f2.close()
except:
f = open('data.txt', 'w')
f.write('tentou ler e nao existia')
f.close()
led = pyb.LED(2)
led.on()
while (1 == 1):
# uart.write('a')
if (uart.any() != 0):
uart.read()
led4 = pyb.LED(4)
led4.on()
break
led3 = pyb.LED(3)
led3.on()
just learning how use it . l was expect that after receive some bytes . the blue led of the board comes on.. then l use de coolterm program to connect to the device and send some string to pyboard .. well, l ve checked all the paramters of serial, 9600 8 n1 , equal at both sides.. but when l push control ctrl-c onto keyboard of macbook , the coolterm shows an keyboard interrupted and keep the REPL onto screnn working. before the ctrl-d the collterm show tx led as it was sending comands but the pyboard doenst shows the blue led . if l remove the uart.any line, the blue led lights, so my conclusion is that l m not receiving any bytes over usb/serial and l dont lnow how to sokve it , at arduino this is works like a charm, l getting crazy to make this work at pyboard world, simples is a much more powerful enviroment and l wanna leran and use.
Another details to help , this is my boot.py
# boot.py -- run on boot-up
# can run arbitrary Python, but best to keep it minimal
import pyb
#pyb.main('main.py') # main script to run after this one
pyb.usb_mode('CDC+MSC') # act as a serial and a storage device
#pyb.usb_mode('CDC+HID') # act as a serial device and a mouse
so guys , any magical tips ?
L tried at windows too , after install the *.inf driver, but had the same issues ...
After hours and hours trying to make my Macbook Send Simple String data to my pyboard v1.1 . l ask aid here ... let me explaind in details so :
L wrote the following python program onto main.py
# main.py -- put your code here!
from pyb import UART
import os
uart = UART(1, 9600)
#uart.init(9600, bits=8, parity=None, stop=1)
#if (os.isfile('data.txt')):
#if (isfile('data.txt')):
# print('data.txt')
# f = open('data.txt', 'r')
# f2 = open('dcopy.txt', 'w')
# f2.write(f.read())
# f2.close()
#else:
try:
f = open('data.txt', 'r')
f2 = open('dcopy.txt', 'w')
f2.write(f.read())
f2.close()
except:
f = open('data.txt', 'w')
f.write('tentou ler e nao existia')
f.close()
led = pyb.LED(2)
led.on()
while (1 == 1):
# uart.write('a')
if (uart.any() != 0):
uart.read()
led4 = pyb.LED(4)
led4.on()
break
led3 = pyb.LED(3)
led3.on()
just learning how use it . l was expect that after receive some bytes . the blue led of the board comes on.. then l use de coolterm program to connect to the device and send some string to pyboard .. well, l ve checked all the paramters of serial, 9600 8 n1 , equal at both sides.. but when l push control ctrl-c onto keyboard of macbook , the coolterm shows an keyboard interrupted and keep the REPL onto screnn working. before the ctrl-d the collterm show tx led as it was sending comands but the pyboard doenst shows the blue led . if l remove the uart.any line, the blue led lights, so my conclusion is that l m not receiving any bytes over usb/serial and l dont lnow how to sokve it , at arduino this is works like a charm, l getting crazy to make this work at pyboard world, simples is a much more powerful enviroment and l wanna leran and use.
Another details to help , this is my boot.py
# boot.py -- run on boot-up
# can run arbitrary Python, but best to keep it minimal
import pyb
#pyb.main('main.py') # main script to run after this one
pyb.usb_mode('CDC+MSC') # act as a serial and a storage device
#pyb.usb_mode('CDC+HID') # act as a serial device and a mouse
so guys , any magical tips ?
L tried at windows too , after install the *.inf driver, but had the same issues ...