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

glass.clear() is terminating Connection #43

Closed
Holladiewal opened this issue Dec 26, 2014 · 9 comments
Closed

glass.clear() is terminating Connection #43

Holladiewal opened this issue Dec 26, 2014 · 9 comments

Comments

@Holladiewal
Copy link

when I use this program: http://pastebin.com/PA92J9PH
it terminates the Connection after a few Seconds, when I wear the glasses.

The Errormessage from the console/log:http://pastebin.com/7YPmFzuB

Hope you can help me

@boq
Copy link
Member

boq commented Dec 26, 2014

Part or problem was your code, recreating objects every tick instead of updating fields, like this:

label = p.addText(10, 10, `Hello`)
label.setText('World')

Object creation is very "heavy" operation, changing single attribute (text, color, position) - not.

Other part of problem was race condition in our code. I fixed it, but now every change has to be manually send to players with .sync() command. This function is limited to one call per tick - don't use it very often in loop.

@boq boq closed this as completed Dec 26, 2014
@Holladiewal
Copy link
Author

So I won't be able to run my program without a sleep(0.5) anymore or it is possible to keep up the live notification system without that sleep?

@boq
Copy link
Member

boq commented Dec 26, 2014

No. As I said, updates are no longer send automatically, you need to call .sync() on peripheral - and this command is automatically limiting update rate to one per tick (execution of program will momentarily pause). No extra limiting needed.

@Holladiewal
Copy link
Author

So I can just keep spamming .sync()?

@boq
Copy link
Member

boq commented Dec 26, 2014

They aren't cheap (one call - one net packet), so no. Once per loop should be enough. One after every addSomething - total waste of bandwidth.

@Holladiewal
Copy link
Author

That was what I meant with spamming. Once per loop without a sleep.

@Holladiewal
Copy link
Author

Tried updating fields in latest verson from jenkins and as soon as i call

l = glass.setText(1,255,"Morning")
l.setText("TEST")

i get the error

lua:1:attempt to call nil

what am i doing wrong?

@boq
Copy link
Member

boq commented Dec 27, 2014

For some time OpenPeripheralCore returned strings instead of objects. Please update that too.

@Holladiewal
Copy link
Author

thanks, now it is working

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

2 participants