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

Possible issue with multiple devices using the same driver #38

Closed
peterhellberg opened this Issue Nov 23, 2013 · 5 comments

Comments

Projects
None yet
2 participants
@peterhellberg

Configured devices

Cylon.robot
  devices:
    [
      { name: 'green', pin: 12, driver: 'led' },
      { name: 'red', pin: 7, driver: 'led' }
    ]

Log output

Starting devices...
Starting device 'green' on pin 12
LED on pin 12 started
Starting device 'red' on pin 7
LED on pin 12 started

Problem

Only the first LED is initialized, if I reorder the lines, then the other LED is initialized instead.

@peterhellberg

This comment has been minimized.

Show comment
Hide comment
@peterhellberg

peterhellberg Nov 23, 2013

Update

I wrote a (quite ugly) hack where I’m using the combined key driverName + opts.pin and it seems to be working for now. Is there a reason why each device loads the driver?

Key in Robot.prototype.requireDriver
this.robot.drivers[driverName + opts.pin]

Update

I wrote a (quite ugly) hack where I’m using the combined key driverName + opts.pin and it seems to be working for now. Is there a reason why each device loads the driver?

Key in Robot.prototype.requireDriver
this.robot.drivers[driverName + opts.pin]
@deadprogram

This comment has been minimized.

Show comment
Hide comment
@deadprogram

deadprogram Nov 23, 2013

Member

Each device is supposed to create an associated driver object of that type. However, I see some errors in how this is currently implemented. We will look into it in bit, thanks for reporting it!

Member

deadprogram commented Nov 23, 2013

Each device is supposed to create an associated driver object of that type. However, I see some errors in how this is currently implemented. We will look into it in bit, thanks for reporting it!

@peterhellberg

This comment has been minimized.

Show comment
Hide comment
@peterhellberg

peterhellberg Nov 23, 2013

Yes, it makes sense that each device has an instance of the driver. However, the driver probably shouldn’t need to be aware of the pin number, right?

Thank you for building all these frameworks, they made for a fun hackday project :)

Yes, it makes sense that each device has an instance of the driver. However, the driver probably shouldn’t need to be aware of the pin number, right?

Thank you for building all these frameworks, they made for a fun hackday project :)

@deadprogram

This comment has been minimized.

Show comment
Hide comment
@deadprogram

deadprogram Nov 24, 2013

Member

I believe the code in the https://github.com/hybridgroup/cylon/tree/correct-driver-arch branch should correct your issue, if you want to give it a try, @peterhellberg

Member

deadprogram commented Nov 24, 2013

I believe the code in the https://github.com/hybridgroup/cylon/tree/correct-driver-arch branch should correct your issue, if you want to give it a try, @peterhellberg

@peterhellberg

This comment has been minimized.

Show comment
Hide comment
@peterhellberg

peterhellberg Nov 25, 2013

Yes, I installed the code from the correct-driver-arch branch, and that did the trick.

This code is now doing what it should:

require('cylon').robot
  connection:
    name: 'arduino', adaptor: 'firmata', port: '/dev/cu.usbmodem1411'

  devices:
    [
      { name: 'red',   pin: 11, driver: 'led' },
      { name: 'green', pin: 10, driver: 'led' }
    ]

  work: (my) ->
    every 1.second(), -> my.red.toggle()
    every 2.second(), -> my.green.toggle()

.start()

Yes, I installed the code from the correct-driver-arch branch, and that did the trick.

This code is now doing what it should:

require('cylon').robot
  connection:
    name: 'arduino', adaptor: 'firmata', port: '/dev/cu.usbmodem1411'

  devices:
    [
      { name: 'red',   pin: 11, driver: 'led' },
      { name: 'green', pin: 10, driver: 'led' }
    ]

  work: (my) ->
    every 1.second(), -> my.red.toggle()
    every 2.second(), -> my.green.toggle()

.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment