Re: Nim lang for Raspberry Pi devices
by Posix driver I meant the Linux implementation in the serial.nim library. You could ask the maintainer to add your baud rate but is probably a bad idea. 1) You say the serial device "is locked" at this rate. Which serial device: your RPi or the linked peer ? 2) I doubt is actually locked, after all is just a value sent to the UART hardware/chipset supporting driver. Let's suppose you run Python on RPi and talk over serial (from your test script) to a Windows box, like TerraTerm or Putty serial port, Kermit, miniTerm or whatever have you on the client end. What's the baud rate of the serial port reported/set on that box? (if using a USB to serial adapter dongle, things may be hidden or rather irrelevant). 3) A wrong or non standard value (250.000 is a bit unusual) will probaby be ignored by the Python implementation (not very sure what it does/details). It may fallback to default value, or round down, or actually use it, or ignore the UART driver response on a stange value? Again, is implementation specific. This may give the caller the "working" state result. 4) advice at this point is try using _a standard value_ (ref: [https://en.wikipedia.org/wiki/Serial_port#Speed](https://en.wikipedia.org/wiki/Serial_port#Speed)) and make sure both ends are set the same. Then try increasing it (again using standard values) till peers no longer able to talk to each other. P.S. watch out that "Handshake.None", it may lead to discarding data if the other side pumps data like crazy. Perhaps use wanted hardware hand-shaking instead? Good luck. Lucian
Re: Nim lang for Raspberry Pi devices
Greetings all! Here is the test code which works perfect on PC: import serial, sequtils, strutils, asyncdispatch when isMainModule: proc readLoop(port: AsyncSerialPort): Future[bool] {.async.} = result = true let futVar = newFutureVar[string]() futVar.mget() = newString(100) var numRead = 0'i32 try: numRead = await port.read(futVar) if numRead > 0: echo "Received ", numRead, " bytes from the serial port: ", futVar.read() except: echo "Error reading from serial port: ", getCurrentExceptionMsg() result = false proc main() {.async.} = let serialPorts = toSeq(listSerialPorts()) echo "Serial Ports" echo "\" for i in low(serialPorts)..high(serialPorts): echo "[", i, "] ", serialPorts[i] echo "" var portName: string while true: write(stdout, "Select port: ") try: let num = parseInt(readLine(stdin)) portName = serialPorts[num] break except: writeLine(stderr, "[ERROR] Invalid port") let serialPort = newAsyncSerialPort(portName) serialPort.open(25, Parity.None, 8, StopBits.One, Handshake.None, readTimeout = 50) while await readLoop(serialPort): discard serialPort.close() asyncCheck main() runForever() 250 000 bods is needed since serial devive is locked with this bodrate. Yes, the error comes from POSIX driver but it defenetly works with Python and pyserial just out of box. Is there any chance to add this non-standard speedrate to POSIX?
Re: Nim lang for Raspberry Pi devices
> The device pluged work on 250k bod : "Unsupported baudrate..." What value are you using exactly for "250K"? That error comes straight from the setSpeed of the posix driver. There is a list of standard baud rates supported. Try lowering or setting explicitly to 115200 , ex: #Section: Reading from/writing to a serial port (echoing data) # use 9600bps, no parity, 8 data bits and 1 stop bit port.open(9600, Parity.None, 8, StopBits.One) # You can modify the baud rate, parity, databits, etc. after opening the port port.baudRate = 115200 Run Make sure the RPi UART is set to support whatever speed you want (it seems to depend on Pi version ; ref: [https://www.raspberrypi.org/documentation/configuration/uart.md](https://www.raspberrypi.org/documentation/configuration/uart.md) with further links to the UART can be found in the SoC peripherals at the bottom of that page); 115200 is pretty standard and a good start value.
Re: Nim lang for Raspberry Pi devices
How are you trying to read from the serial in Nim?
Re: Nim lang for Raspberry Pi devices
Raspbian already provides the official Nim 1.0.6 package from Debian: [https://archive.raspbian.org/raspbian/pool/main/n/nim](https://archive.raspbian.org/raspbian/pool/main/n/nim)/
Re: Nim lang for Raspberry Pi devices
Thanks, shashlick, may be I'll check it as well. One more question I currently troubled: I'm trying to reach serial port from RPi. The device pluged work on 250k bod... It works perfect on RPi with Python pyserial. It works fine with nim serial lib under windows But when trying the same nim prog under RPi is returns "Unsupported baudrate..." Any ideas what to do?
Re: Nim lang for Raspberry Pi devices
Nim is available precompiled for RPi (armv6) on the nightlies releases page. [https://github.com/nim-lang/nightlies/releases](https://github.com/nim-lang/nightlies/releases)
Re: Nim lang for Raspberry Pi devices
Thanks for answer! Actually I just have downloaded the source and built it straight on raspberry. And it works finally! Now lets see how it works there
Re: Nim lang for Raspberry Pi devices
It's not a problem. For example: [https://github.com/status-im/nim-beacon-chain#raspberry-pi](https://github.com/status-im/nim-beacon-chain#raspberry-pi) Some comments: * The swap file was for a RocksDB dependency that was taken over 1GB of RAM but compiling the Nim compiler itself might require that as well * The go dependency is unrelated And for a pure Nim package you can check the CI for ARM I use in my libraries: * [https://github.com/mratsim/weave/blob/master/.travis.yml#L21-L26](https://github.com/mratsim/weave/blob/master/.travis.yml#L21-L26) Tested on 32 cores ARM device on Travis: [https://travis-ci.com/github/mratsim/weave/jobs/285368794](https://travis-ci.com/github/mratsim/weave/jobs/285368794)
Nim lang for Raspberry Pi devices
Dear All, I'm a beginner in NimLang and i'm trying to use it to make some programs for Raspberry PI microcomputer (ARM proc, Raspbian(Debian) OS). Please advise: Is the latest (1.x?) compiler version is available for that system - since official cite link result in 0.19.4 version only? Or cross compilation should be used (if possible)? Is there any specific for this system compared to Linux? Does anybode have experience using Nim for Raspberry?