Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import strutils
- import nesper/general, nesper/uarts, nesper/gpios, nesper/tasks
- import bytesequtils
- import ./example
- import ./tasks as mytasks
- proc sendAT() =
- var conf = newUartConfig(
- stop_bits = UART_STOP_BITS_1,
- data_bits = UART_DATA_8_BITS,
- parity = UART_PARITY_DISABLE,
- flow_ctrl = UART_HW_FLOWCTRL_DISABLE)
- var urt1 = newUart(
- uart_num = UART_NUM_1,
- config = conf,
- tx_pin = gpios.GPIO_NUM_17,
- rx_pin = gpios.GPIO_NUM_16,
- buffer = 16_384.SzBytes)
- while true:
- echo "Writing to the uart..."
- var len = urt1.write("AT\r")
- echo $len
- # check: uart_wait_tx_done(urt1.port, 100)
- echo "Here is where I'd read it..."
- vTaskDelay(10)
- var buf = urt1.read()
- if buf.len > 0:
- var res = buf.toStrBuf()
- echo "'" & res & "'"
- echo res.contains("OK")
- echo res == "OK"
- vTaskDelay(300)
- app_main():
- echo "Hello, Nim!"
- example.run()
- var t: Task = newTask(sendAT, "sendAT", (16384 * 3).SzBytes)
- if t.ret == pdPASS:
- echo "Created task successfully!"
- # discard xTaskCreate(sendAT, "sendAT", 16384 * 3, nil, 10, nil)
- assert false, "Should never get here"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement