Using Port 80 with SimPixel

Hello!

I am using BiblioPixel and SimPixel to help teachers who want to introduce their students to coding with LEDs. I want to eventually use BiblioPixel on online development environments that have limited ports and be able to connect to SimPixel with port 80.

Currently I am working on my local machine (MacBook). I have been able to change the port to other four-digit port numbers and display on SimPixel just fine. However, when I choose port 80 for the driver in my project config, I get this cryptic error message:

ERROR: ‘NoneType’ object has no attribute ‘update’

``

Why might port 80 not be valid? I hope someone can point me in the right direction!

···

I run the project with this command:

bibliopixel run project.json

``

Below are my project files:

project.json

{

“animation”: “support.StripStudent”,

“driver”: {

“num”: 12,

“typename”: “SimPixel”,

“port”: 5000

},

“run”: {

“max_steps”: 50

}

}

``

support.py

from bibliopixel.animation.strip import BaseStripAnim

from bibliopixel.util import colors

class StripStudent(BaseStripAnim):

def __init__(self, layout):

    super().__init__(layout)

    self.internal_delay = 0.500

def step(self, amt=1):

    for i in range(12):

        if (self.cur_step % 2 == 0):

            self.layout.set(i, colors.Red)

        else:

            self.layout.set(i, colors.Green)

``

Sounds awesome! Super happy to hear BiblioPixel is being used for education!
So, the bad news is that you really can’t use port 80. Unix-based systems disallow binding to any port below 1024 for non-root users. Calling sudo bp run project.json would work but every SysOps guy I know would slap me if they knew I recommended you let a bunch of students interact with a root process.

Note: in case the students are actually using windows machines, this is not an issue on windows :slight_smile:

In theory you could use authbind (https://github.com/Castaglia/MacOSX-authbind) then call authbind --deep bp run project.json (I have not tested this, as I don’t have a Mac). Note, first you have to configure authbind with:


sudo touch /etc/authbind/byport/80

sudo chmod 777 /etc/authbind/byport/80

So, I’m not really sure if that’s a valid option for you. But hopefully it’s a start. Let me know how that goes and if not maybe we can work something else out.

Cheers!

Adam

···

On Mon, Apr 2, 2018 at 7:39 PM, vinesh@mimirhq.com wrote:

Hello!

I am using BiblioPixel and SimPixel to help teachers who want to introduce their students to coding with LEDs. I want to eventually use BiblioPixel on online development environments that have limited ports and be able to connect to SimPixel with port 80.

Currently I am working on my local machine (MacBook). I have been able to change the port to other four-digit port numbers and display on SimPixel just fine. However, when I choose port 80 for the driver in my project config, I get this cryptic error message:

ERROR: ‘NoneType’ object has no attribute ‘update’

``

Why might port 80 not be valid? I hope someone can point me in the right direction!


I run the project with this command:

bibliopixel run project.json

``

Below are my project files:

project.json

{

“animation”: “support.StripStudent”,

“driver”: {

“num”: 12,

“typename”: “SimPixel”,

“port”: 5000

},

“run”: {

“max_steps”: 50

}

}

``

support.py

from bibliopixel.animation.strip import BaseStripAnim

from bibliopixel.util import colors

class StripStudent(BaseStripAnim):

def __init__(self, layout):
    super().__init__(layout)
    self.internal_delay = 0.500
def step(self, amt=1):
    for i in range(12):
        if (self.cur_step % 2 == 0):
            self.layout.set(i, colors.Red)
        else:
            self.layout.set(i, colors.Green)

``

You received this message because you are subscribed to the Google Groups “Maniacal Labs Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to maniacal-labs-users+unsubscribe@googlegroups.com.

To post to this group, send email to maniacal-labs-users@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/maniacal-labs-users/84f23f05-20e7-419c-a313-922dfc2c4670%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Thanks a lot, Adam and Tom! That worked for me.

On the web-based IDE we use, the students bind to a virtual, restricted port 80 that actually maps to a new DNS name that has SSL. Then, by using wss:// instead of ws:// I was able to display on SimPixel. I will add notes in the lesson plans about why the ports are restricted.

Even though the port on this particular platform is restricted and secure, is there anything else a student should know about running the project with sudo?

Vinesh

···

On Monday, April 2, 2018 at 7:28:12 PM UTC-5, Adam Haile wrote:

Sounds awesome! Super happy to hear BiblioPixel is being used for education!
So, the bad news is that you really can’t use port 80. Unix-based systems disallow binding to any port below 1024 for non-root users. Calling sudo bp run project.json would work but every SysOps guy I know would slap me if they knew I recommended you let a bunch of students interact with a root process.

Note: in case the students are actually using windows machines, this is not an issue on windows :slight_smile:

In theory you could use authbind (https://github.com/Castaglia/MacOSX-authbind) then call authbind --deep bp run project.json (I have not tested this, as I don’t have a Mac). Note, first you have to configure authbind with:

sudo touch /etc/authbind/byport/80

sudo chmod 777 /etc/authbind/byport/80

So, I’m not really sure if that’s a valid option for you. But hopefully it’s a start. Let me know how that goes and if not maybe we can work something else out.

Cheers!

Adam

On Mon, Apr 2, 2018 at 7:39 PM, vin...@mimirhq.com wrote:

Hello!

I am using BiblioPixel and SimPixel to help teachers who want to introduce their students to coding with LEDs. I want to eventually use BiblioPixel on online development environments that have limited ports and be able to connect to SimPixel with port 80.

Currently I am working on my local machine (MacBook). I have been able to change the port to other four-digit port numbers and display on SimPixel just fine. However, when I choose port 80 for the driver in my project config, I get this cryptic error message:

ERROR: ‘NoneType’ object has no attribute ‘update’

``

Why might port 80 not be valid? I hope someone can point me in the right direction!


I run the project with this command:

bibliopixel run project.json

``

Below are my project files:

project.json

{

“animation”: “support.StripStudent”,

“driver”: {

“num”: 12,

“typename”: “SimPixel”,

“port”: 5000

},

“run”: {

“max_steps”: 50

}

}

``

support.py

from bibliopixel.animation.strip import BaseStripAnim

from bibliopixel.util import colors

class StripStudent(BaseStripAnim):

def __init__(self, layout):
    super().__init__(layout)
    self.internal_delay = 0.500
def step(self, amt=1):
    for i in range(12):
        if (self.cur_step % 2 == 0):
            self.layout.set(i, colors.Red)
        else:
            self.layout.set(i, colors.Green)

``

You received this message because you are subscribed to the Google Groups “Maniacal Labs Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to maniacal-labs-users+unsubscribe@googlegroups.com.

To post to this group, send email to maniacal-...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/maniacal-labs-users/84f23f05-20e7-419c-a313-922dfc2c4670%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Excellent :slight_smile:

As for running with sudo… just that it would be bad practice. You’re giving an unrestricted server process full root access, which means if someone found an exploit in our code they could hack your system. I mean… that’s highly unlikely in your situation. But we also don’t exactly audit the SimPixel code for critical security exploits :wink:

That was purely a matter of “here’s the easiest way to fix it, but here be security dragons”.

···

On Tue, Apr 3, 2018 at 12:58 PM, vinesh@mimirhq.com wrote:

Thanks a lot, Adam and Tom! That worked for me.

On the web-based IDE we use, the students bind to a virtual, restricted port 80 that actually maps to a new DNS name that has SSL. Then, by using wss:// instead of ws:// I was able to display on SimPixel. I will add notes in the lesson plans about why the ports are restricted.

Even though the port on this particular platform is restricted and secure, is there anything else a student should know about running the project with sudo?

Vinesh

On Monday, April 2, 2018 at 7:28:12 PM UTC-5, Adam Haile wrote:

Sounds awesome! Super happy to hear BiblioPixel is being used for education!
So, the bad news is that you really can’t use port 80. Unix-based systems disallow binding to any port below 1024 for non-root users. Calling sudo bp run project.json would work but every SysOps guy I know would slap me if they knew I recommended you let a bunch of students interact with a root process.

Note: in case the students are actually using windows machines, this is not an issue on windows :slight_smile:

In theory you could use authbind (https://github.com/Castaglia/MacOSX-authbind) then call authbind --deep bp run project.json (I have not tested this, as I don’t have a Mac). Note, first you have to configure authbind with:

sudo touch /etc/authbind/byport/80

sudo chmod 777 /etc/authbind/byport/80

So, I’m not really sure if that’s a valid option for you. But hopefully it’s a start. Let me know how that goes and if not maybe we can work something else out.

Cheers!

Adam

On Mon, Apr 2, 2018 at 7:39 PM, vin...@mimirhq.com wrote:

Hello!

I am using BiblioPixel and SimPixel to help teachers who want to introduce their students to coding with LEDs. I want to eventually use BiblioPixel on online development environments that have limited ports and be able to connect to SimPixel with port 80.

Currently I am working on my local machine (MacBook). I have been able to change the port to other four-digit port numbers and display on SimPixel just fine. However, when I choose port 80 for the driver in my project config, I get this cryptic error message:

ERROR: ‘NoneType’ object has no attribute ‘update’

``

Why might port 80 not be valid? I hope someone can point me in the right direction!


I run the project with this command:

bibliopixel run project.json

``

Below are my project files:

project.json

{

“animation”: “support.StripStudent”,

“driver”: {

“num”: 12,

“typename”: “SimPixel”,

“port”: 5000

},

“run”: {

“max_steps”: 50

}

}

``

support.py

from bibliopixel.animation.strip import BaseStripAnim

from bibliopixel.util import colors

class StripStudent(BaseStripAnim):

def __init__(self, layout):
    super().__init__(layout)
    self.internal_delay = 0.500
def step(self, amt=1):
    for i in range(12):
        if (self.cur_step % 2 == 0):
            self.layout.set(i, colors.Red)
        else:
            self.layout.set(i, colors.Green)

``

You received this message because you are subscribed to the Google Groups “Maniacal Labs Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to maniacal-labs-users+unsubscribe@googlegroups.com.

To post to this group, send email to maniacal-...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/maniacal-labs-users/84f23f05-20e7-419c-a313-922dfc2c4670%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “Maniacal Labs Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to maniacal-labs-users+unsubscribe@googlegroups.com.

To post to this group, send email to maniacal-labs-users@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/maniacal-labs-users/e49e20e7-19b7-4693-b31b-c9d461d16644%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

usermod -a -G spi dialout <username>

Always do the above with every Pi I own… will allow non-root access to SPI and serial devices.

···

On Tue, Apr 3, 2018 at 1:36 PM, Tom Swirly tom@swirly.com wrote:

This isn’t the end of the earth - we’re going to be running with sudo in some cases in practice anyway.

To read the keyboard continuously on the Mac, you need sudo access. Don’t complain to me about that, not my fault! :smiley:

If we use SPI on RPi, we also need sudo access, don’t we?

On Tue, Apr 3, 2018 at 7:10 PM, Adam Haile adammhaile@gmail.com wrote:

Excellent :slight_smile:

As for running with sudo… just that it would be bad practice. You’re giving an unrestricted server process full root access, which means if someone found an exploit in our code they could hack your system. I mean… that’s highly unlikely in your situation. But we also don’t exactly audit the SimPixel code for critical security exploits :wink:

That was purely a matter of “here’s the easiest way to fix it, but here be security dragons”.

You received this message because you are subscribed to the Google Groups “Maniacal Labs Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to maniacal-labs-users+unsubscribe@googlegroups.com.

To post to this group, send email to maniacal-labs-users@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/maniacal-labs-users/CAG8g-Tb47-e61rG%3D9JnM693iCAANJGZOawydb9g1_7nP0X7zHQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


/t

https://tom.ritchford.com

https://tom.swirly.com

On Tue, Apr 3, 2018 at 12:58 PM, vinesh@mimirhq.com wrote:

Thanks a lot, Adam and Tom! That worked for me.

On the web-based IDE we use, the students bind to a virtual, restricted port 80 that actually maps to a new DNS name that has SSL. Then, by using wss:// instead of ws:// I was able to display on SimPixel. I will add notes in the lesson plans about why the ports are restricted.

Even though the port on this particular platform is restricted and secure, is there anything else a student should know about running the project with sudo?

Vinesh

On Monday, April 2, 2018 at 7:28:12 PM UTC-5, Adam Haile wrote:

Sounds awesome! Super happy to hear BiblioPixel is being used for education!
So, the bad news is that you really can’t use port 80. Unix-based systems disallow binding to any port below 1024 for non-root users. Calling sudo bp run project.json would work but every SysOps guy I know would slap me if they knew I recommended you let a bunch of students interact with a root process.

Note: in case the students are actually using windows machines, this is not an issue on windows :slight_smile:

In theory you could use authbind (https://github.com/Castaglia/MacOSX-authbind) then call authbind --deep bp run project.json (I have not tested this, as I don’t have a Mac). Note, first you have to configure authbind with:

sudo touch /etc/authbind/byport/80

sudo chmod 777 /etc/authbind/byport/80

So, I’m not really sure if that’s a valid option for you. But hopefully it’s a start. Let me know how that goes and if not maybe we can work something else out.

Cheers!

Adam

On Mon, Apr 2, 2018 at 7:39 PM, vin...@mimirhq.com wrote:

Hello!

I am using BiblioPixel and SimPixel to help teachers who want to introduce their students to coding with LEDs. I want to eventually use BiblioPixel on online development environments that have limited ports and be able to connect to SimPixel with port 80.

Currently I am working on my local machine (MacBook). I have been able to change the port to other four-digit port numbers and display on SimPixel just fine. However, when I choose port 80 for the driver in my project config, I get this cryptic error message:

ERROR: ‘NoneType’ object has no attribute ‘update’

``

Why might port 80 not be valid? I hope someone can point me in the right direction!


I run the project with this command:

bibliopixel run project.json

``

Below are my project files:

project.json

{

“animation”: “support.StripStudent”,

“driver”: {

“num”: 12,

“typename”: “SimPixel”,

“port”: 5000

},

“run”: {

“max_steps”: 50

}

}

``

support.py

from bibliopixel.animation.strip import BaseStripAnim

from bibliopixel.util import colors

class StripStudent(BaseStripAnim):

def __init__(self, layout):
    super().__init__(layout)
    self.internal_delay = 0.500
def step(self, amt=1):
    for i in range(12):
        if (self.cur_step % 2 == 0):
            self.layout.set(i, colors.Red)
        else:
            self.layout.set(i, colors.Green)

``

You received this message because you are subscribed to the Google Groups “Maniacal Labs Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to maniacal-labs-users+unsubscribe@googlegroups.com.

To post to this group, send email to maniacal-...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/maniacal-labs-users/84f23f05-20e7-419c-a313-922dfc2c4670%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “Maniacal Labs Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to maniacal-labs-users+unsubscribe@googlegroups.com.

To post to this group, send email to maniacal-labs-users@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/maniacal-labs-users/e49e20e7-19b7-4693-b31b-c9d461d16644%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.