Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for 921600 baudrate #3

Open
pallix opened this issue Nov 15, 2017 · 7 comments
Open

Support for 921600 baudrate #3

pallix opened this issue Nov 15, 2017 · 7 comments

Comments

@pallix
Copy link
Contributor

pallix commented Nov 15, 2017

Hello,

I tried to extend the code to get a baudrate of 921600 by adding:

else if (speed == 921600) {
    cfsetispeed(&fdt, B921600);
    cfsetospeed(&fdt, B921600);
  } 

However, after testing the change by using your baud library, I notice that the data are transmitted wrongly: inputs and outputs do not match.

@samuelventura
Copy link
Owner

Can you share what code you test the output/input with?

@pallix
Copy link
Contributor Author

pallix commented Nov 16, 2017

I made a second try and it works. Sorry for that. I did test a lot of things yesterday, maybe I forgot to set the baudrate on the receiver?

Just for the record the code is:

defmodule BaudEvaluation.Write do
  @moduledoc """
  Write to the serial port
  """

  @buff_size 1024

  def write(filename) do
    device = Application.get_env(:baud_evaluation, :writeDeviceName)
    IO.puts device
    {:ok, serial} = Baud.start_link([device: device, speed: 921600])
    file = File.open!(filename)
    write_loop(serial, file)
  end

  def write_loop(serial, file) do
    case IO.binread(file, @buff_size) do
      :eof -> IO.puts "done"
      {:error, reason} -> IO.puts("Error" <> reason)
      content ->
        IO.puts(byte_size(content))
        Baud.write(serial, content)
        write_loop(serial, file)
    end
  end

end

I will submit a PR for the baudrate.

@jvf
Copy link

jvf commented Jan 3, 2018

The new baudrates from #4 break building sniff on macOS. Tested on macOS 10.12.6 (16G1114).

See tomszilagyi/gen_serial#1 for a description of the problem and Gottox/node-termios#2 for a possible solution.

@pallix
Copy link
Contributor Author

pallix commented Jan 30, 2018

@samuelventura any news on fixing the MacOS issue?

@samuelventura
Copy link
Owner

185b67d introduces separated baudrate files for linux/darwin. Both compile after that.

@pallix
Copy link
Contributor Author

pallix commented Jan 31, 2018

That is awesome. Many thanks for your work!

@samuelventura
Copy link
Owner

@jvf Thank you for your research on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants