Code Monkey home page Code Monkey logo

Comments (8)

bazfum avatar bazfum commented on July 23, 2024 2

Interesting. After making those changes the file transmits fine as far as the Pi is concerned. It seems like getting it to receive all the data happily will require some trial and error on LED positioning. Thanks for all the assistance!

from timex_datalink_client.

bazfum avatar bazfum commented on July 23, 2024 1

Thanks, that got me through a lot of progress! I had to update the Pi more than I'd expected since the compiler wasn't working, and then had to trace down a few dependancies but that's par for the course. I'm now getting some data transferred and then an error:

jac@pi400:~ $ ruby ebrain.ruby
78 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 AA AA AA AA AA
07 20 00 00 07 C2 FF
26 90 05 0E 44 53 49 20 54 6F 79 73 20 70 72 65 73 65 6E 74 73 2E 2E 2E 65 42 72 61 69 6E 21 00 00 00 00 00 36 63
26 91 05 01 02 00 00 00 02 00 07 1E 02 10 00 08 00 01 15 00 7C 90 3E FE 00 97 A5 44 E2 FF 1C 9A 36 FF 00 04 82 64
26 91 05 02 55 01 84 03 30 63 FE 00 00 30 69 FE 00 00 02 02 00 78 ..FEFB /home/jac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.2/lib/timex_datalink_client/notebook_adapter.rb:35:in chr': -261 out of char range (RangeError) from /home/jac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.2/lib/timex_datalink_client/notebook_adapter.rb:35:in block (2 levels) in write'
from /home/jac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.2/lib/timex_datalink_client/notebook_adapter.rb:32:in each' from /home/jac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.2/lib/timex_datalink_client/notebook_adapter.rb:32:in block in write'
from /home/jac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.2/lib/timex_datalink_client/notebook_adapter.rb:31:in each' from /home/jac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.2/lib/timex_datalink_client/notebook_adapter.rb:31:in write'
from /home/jac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.2/lib/timex_datalink_client.rb:113:in write' from ebrain.ruby:111:in

'

from timex_datalink_client.

synthead avatar synthead commented on July 23, 2024

Heya! Very fun story about your e-BRAIN, and thanks for filing this issue!

It appears that you're attempting to use this lib with an old Ruby version! This lib uses omitted keyword arguments, which is a feature introduced in Ruby 3.1.0:

  • Values in Hash literals and keyword arguments can be omitted. [Feature #14579]

    • {x:, y:} is syntax sugar for {x: x, y: y}.
    • foo(x:, y:) is syntax sugar for foo(x: x, y: y).

You can see what Ruby version you're running with this command:

$ ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]

To get a newer version of Ruby, I recommend rbenv! This will let you build and install Ruby as a local installation in your home directory. This allows you to install any recent version without relying on your distro to supply it for you.

Here's how you can get rbenv running on your Raspberry Pi 400!

First, clone rbenv to ~/.rbenv:

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

Then add rbenv as a hook to your ~/.bashrc:

echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc

Log out of your console and log back in to load the eval you added to your ~/.bashrc. Then, add the ruby-build plugin to your local rbenv installation (in ~/.rbenv):

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Now you have rbenv! You can now install Ruby 3.2.2 (the latest stable version as of this writing) like this:

rbenv install -v 3.2.2

And then you can set Ruby 3.2.2 as the default Ruby (for only your local Bash sessions) with:

rbenv global 3.2.2

With your new Ruby available, you'll want to install the timex_datalink_client gem for the Ruby 3.2.2 installation:

gem install timex_datalink_client

And you should be good to go! Try running your script; it'll probably work great from here 👍

Let me know how it goes!

from timex_datalink_client.

synthead avatar synthead commented on July 23, 2024

I just filed this issue! This should help folks in the future 👍

Edit: shipped a PR to address ☝️:

from timex_datalink_client.

synthead avatar synthead commented on July 23, 2024

Just shipped a fix to README.md to mention the minimum Ruby version, too:

from timex_datalink_client.

synthead avatar synthead commented on July 23, 2024

Hey great! I'm really glad this got the gem working! Thank you for sharing your progress!

This is a really interesting one! I was able to reproduce this on my end, and I found that the negative integer (that's supposed to represent a byte) is originating from this method:

def time_formatted(device_time)
device_time_midnight = Time.new(device_time.year, device_time.month, device_time.day)
seconds = (time - device_time_midnight).to_i
five_minutes = seconds / FIVE_MINUTES_SECONDS
lsb_msb_format_for(five_minutes)
end

I discovered that the negative number comes from comparing dates between the current time and calendar events. At some point, an error state happens when the synced time is too far in the future compared to an event.

The unit tests for this class still pass because all the times in the tests are fixed. The complete code example in the protocol 7 documentation doesn't work because it uses Time.now to get the current time, which is constantly changing.

I'll get a fix up for this soon! In the meantime, you can simply omit the calendar events or set the events to a later time, i,e, 2023 instead of 2022. For example, here is the updated events array with the updated year that is tested to work:

events = [
  TimexDatalinkClient::Protocol7::Eeprom::Calendar::Event.new(
    time: Time.new(2023, 12, 13, 9, 0, 0),
    phrase: breakfast_with_cousins
  ),
  TimexDatalinkClient::Protocol7::Eeprom::Calendar::Event.new(
    time: Time.new(2023, 12, 13, 19, 0, 0),
    phrase: crashing_around_the_house
  )
]

from timex_datalink_client.

synthead avatar synthead commented on July 23, 2024

Ah great! I'm glad to hear that! Have fun playing with your e-BRAIN! 😄

The e-BRAIN has a really insensitive optical sensor, and yeah, you really have to blast it with light for it to transfer reliably. I haven't tested syncing it with a CRT, but it seems like it would be difficult to have a successful transfer that way, too.

On my DIY Notebook Adapter, I have an external LED soldered to it, and it works great. On a Datalink 150, I can sync it from several feet away. It also syncs to an e-BRAIN nicely. You might consider soldering an LED onto your own adapter for a reliable transfer 🙂

Here's my personal Teensy LC with an LED soldered onto it!

image

More information about this here!

from timex_datalink_client.

synthead avatar synthead commented on July 23, 2024

Hi @bazfum! I just released version 0.12.3 with fixes to accommodate for your issues!

Here are the pull requests that target the problems you were seeing:

This new release does not add any functional changes to any current happy paths, so if your code is working now, it should continue to work. However, if your Ruby version is too old or your e-BRAIN calendar events are in the past, meaningful errors will now be raised (instead of the obscure, uncaught ones in v0.12.2).

Additionally, the protocol 7 (e-BRAIN) documentation now uses calendar event times based on the device time by using times for tomorrow. This will ensure that the complete code example will always work, no matter what the current time is 👍

To obtain the latest version of timex_datalink_client, simply do this in a console:

gem update timex_datalink_client

This should produce output like this:

$ gem update timex_datalink_client
Updating installed gems
Updating timex_datalink_client
Successfully installed timex_datalink_client-0.12.3
Parsing documentation for timex_datalink_client-0.12.3
Installing ri documentation for timex_datalink_client-0.12.3
Done installing documentation for timex_datalink_client after 0 seconds
Parsing documentation for timex_datalink_client-0.12.3
Done installing documentation for timex_datalink_client after 0 seconds
Gems updated: timex_datalink_client

Since you got your e-BRAIN working, I'll go ahead and close this issue since the bugs have been fixed 👍 Feel free to reopen this issue or file a new one if you run into any more problems!

from timex_datalink_client.

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.