Search found 3482 matches

by dhylands
Thu Aug 13, 2020 4:07 pm
Forum: General Discussion and Questions
Topic: While True loop Stopping
Replies: 7
Views: 525

Re: While True loop Stopping

It would be more efficient to just use:

Code: Select all

  if data:
rather than converting data to a string, or perhaps using

Code: Select all

if data is not None:
Be aware that read may return more than 1 byte, so be prepared for that scenario.
by dhylands
Thu Aug 13, 2020 4:01 pm
Forum: Development of MicroPython
Topic: MicroPython firmwares with "'MICROPY_PY_REVERSE_SPECIAL_METHODS'" enabled ?
Replies: 16
Views: 1186

Re: MicroPython firmwares with "'MICROPY_PY_REVERSE_SPECIAL_METHODS'" enabled ?

Most features like that have flags just because the code takes up space that smaller devices might not want. You'll generally find that these options are on by default for the unix build https://github.com/micropython/micropython/blob/master/ports/unix/mpconfigport.h#L103 and the stm32 builds (altho...
by dhylands
Thu Aug 13, 2020 1:56 pm
Forum: Other Boards
Topic: WeAct STM32F411CEU6 black pill
Replies: 29
Views: 10896

Re: WeAct STM32F411CEU6 black pill

It looks to me like I2C1 should be on pins B8/B9 (based on your dump), and B6/B7 are configured back as GPIOs (the pull parameter being dropped is the clue here). Just FYI: when you use machine.I2C and an id of -1, then it will do software I2C which uses the pins in GPIO mode and this mode can use a...
by dhylands
Thu Aug 13, 2020 1:42 pm
Forum: General Discussion and Questions
Topic: While True loop Stopping
Replies: 7
Views: 525

Re: While True loop Stopping

That same documentation also tells you how to do a non-blocking read.
by dhylands
Wed Aug 12, 2020 5:16 pm
Forum: General Discussion and Questions
Topic: While True loop Stopping
Replies: 7
Views: 525

Re: While True loop Stopping

stdin doesn't have an any() method, so you can either use the USB_VCP device or UART device depending on which microprocessor you're using. http://docs.micropython.org/en/latest/library/pyb.USB_VCP.html#pyb.USB_VCP.any http://docs.micropython.org/en/latest/library/machine.UART.html#machine.UART.any ...
by dhylands
Tue Aug 11, 2020 8:00 pm
Forum: Other Boards
Topic: WeAct STM32F411CEU6 black pill
Replies: 29
Views: 10896

Re: WeAct STM32F411CEU6 black pill

One option is to create a custom board type and modify the mpconfigboard.h file: https://github.com/mcauser/WEACT_F411CEU6/blob/40061c9ed43dc7fb5e0363f808843ce2cda7e0e1/mpconfigboard.h#L39-L44 Another option is to open I2C1 and then modify the pin mux afterwards. Here's some example code that does t...
by dhylands
Mon Aug 10, 2020 5:31 pm
Forum: Other Boards
Topic: WeAct STM32F411CEU6 black pill
Replies: 29
Views: 10896

Re: WeAct STM32F411CEU6 black pill

The "X" and "Y" names come from the boards mpconfigboard.h file. For the pyboard, it's here: https://github.com/micropython/micropython/blob/9883d8e818feba112935676eb5aa4ce211d7779c/ports/stm32/boards/PYBV11/mpconfigboard.h#L56 The WeAct board config file doesn't provide any names and I'm not sure w...
by dhylands
Thu Aug 06, 2020 6:23 pm
Forum: Pyboard D-series
Topic: Trouble with uart.read()
Replies: 6
Views: 987

Re: Trouble with uart.read()

Also, how are you controlling the direction? With RS-485 you need to have a GPIO line or something controlling the direction. I found that controlling that line from python wasn't fast enough and I would miss response characters from the servo. So I had to write the sending portion in assembler to g...
by dhylands
Thu Aug 06, 2020 6:14 pm
Forum: Pyboard D-series
Topic: Trouble with uart.read()
Replies: 6
Views: 987

Re: Trouble with uart.read()

When you send the command to servo 1, you need to wait for the response before sending the command to servo 2. Otherwise your command to servo 2 and the response from servo 1 will trample each other. Only one device can transmit at a time, and the host needs to orchestrate that. I believe that there...
by dhylands
Thu Aug 06, 2020 6:07 pm
Forum: Pyboard D-series
Topic: Trouble with uart.read()
Replies: 6
Views: 987

Re: Trouble with uart.read()

I always just read single characters using uart.read and assemble the packets. I've found that trying to do anything else inevitably breaks down. There is an RX buffer that you can control the size of when you open the UART. If you're expecting multiple messages then it should be big enough to hold ...