GithubHelp home page GithubHelp logo

Comments (2)

fhunleth avatar fhunleth commented on May 27, 2024

FYI - I'm working on this feature the lines branch. Hopefully I'll get it merged to master and make a release soon. The framing of packets is done via a behaviour, but there's a built-in one for lines. Just add the :framing parameter to your Nerves.UART.open or Nerves.UART.configure calls.

Here's an example for passive mode, but active mode works similarly:

iex> {:ok, uart}= Nerves.UART.start_link      
{:ok, #PID<0.186.0>}
iex> Nerves.UART.open(uart, "ttyUSB0", speed: 9600, active: false)
:ok
iex> Nerves.UART.read(uart)
{:ok,
 "$PGTOP,11,2*6E\r\n$GPGGA,000209.800,,,,,0,0,,,M,,M,,*4B\r\n$GPGSA,A,1,,,,,,,,,,,,,,,*1E\r\n$GPRMC,000209.800,V,,,,,0.00,0.00,060180,,,N*41\r\n$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32\r\n$PGTOP,11,2*6E\r\n$GPGGA,000210.800,,,,,0,0,,,M,,M,,*43\r\n$GPGSA,A,1,,,,,,,,,,,,,,,*1E\r\n$GPRMC,000210.800,V,,,,,0.00,0.00,060180,,,N*49\r\n"}
iex> Nerves.UART.configure(uart, framing: {Nerves.UART.Framing.Line, separator: "\r\n"})
:ok
iex> Nerves.UART.read(uart)
{:ok, "$GPGGA,000226.800,,,,,0,0,,,M,,M,,*46"}
iex> Nerves.UART.read(uart)
{:ok, "$GPRMC,000226.800,V,,,,,0.00,0.00,060180,,,N*4C"}

Since you're breaking on "\n" characters, you don't need to specify the separator. I.e. adding framing: Nerves.UART.Framing.Line to your Nerves.UART.open call is sufficient.

from circuits_uart.

fhunleth avatar fhunleth commented on May 27, 2024

The v0.1.0 release has this feature now. Closing this issue. If there are limitations with what I added, then let's open new issues up so that they can be addressed.

@mattneel, thanks for bring this issue up! I think this will help many people.

from circuits_uart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.