arduino communication problems

#1

Hi,

I am trying to do a fairly basic communication between an arduino and a websocket and client. I am sorry for any completely obvious errors or misunderstandings, I am pretty new to this.

I have used and slightly modified the example given on https://github.com/tavendo/AutobahnPython/tree/master/examples/wamp/serial2ws

My code is supposed to send a simple command from a python client to make the arduino blink 5 times. I think I am having an issue with the communication between the server and the arduino as the command seems to be called properly by the client but no blinking or response is given by the arduino.

I am also unsure exactly of how pubsub is supposed to work. Once I my client has subscribed to a topic, will it automatically receive any messages sent to that topic?

It is important to me for another project that I can receive data sent by the arduino to a python client.

All the code is attached. I am using a Ubuntu virutal unix machine.

Thanks so much for any help.

Dan D

serialclient2.py (2.43 KB)

serialserver_dan.py (4.35 KB)

blinkpython.ino (621 Bytes)

0 Likes

#2

Hi,
I am trying to do a fairly basic communication between an arduino and a
websocket and client. I am sorry for any completely obvious errors or
misunderstandings, I am pretty new to this.

Nothing to apologize. I will try a first round .. expect some learning experience;)

I have used and slightly modified the example given on
https://github.com/tavendo/AutobahnPython/tree/master/examples/wamp/serial2ws

That is good! In general, start with an example, assure yourself it works, and only then modify it. That way, you always have a "known good".

Now with the Arduino stuff the limit with this is of course that any example will depend on concrete hardware. Or is there any hardware that is built into every Arduino? If so, we probably should have an example for that.

My code is supposed to send a simple command from a python client to
make the arduino blink 5 times. I think I am having an issue with the
communication between the server and the arduino as the command seems to
be called properly by the client but no blinking or response is given by
the arduino.

There are 2 parts in your system:

1) WAMP Client === WAMP / WebSocket ===> WAMP Server
2) WAMP Server === Your Proto / Serial ===> Arduino

Regarding 1), there is a principle issue with your code: sleep()

AutobahnPython is based Twisted, and this is a _asynchronous_ library which runs under a thing called a "reactor". There are many good intros on the net, suffice to say: you must not block the reactor.

And sleep(), like other functions form the Python standard library do block. Now it might look like some things work even if you do bad blocking, but it is wrong and will result in all kinds of strange and hard to debug problems. In short: there is no way around getting familiar with the asynchronous programming approach. Like JavaScript in the browser: everything is event driven.

Here is a WAMP client that publishes periodically:

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/pubsub/simple/example1/client.py

It uses reactor.callLater() - and that will not block the reactor.

Regarding PubSub (simplified):

You subscribe and publish from the client.
You register a topic for PubSub on the server.

The "True" argument to registerForPubSub registers not only the specific topic given, but all topics that have the given prefix.

When you publish from a client, that client is by default excluded from the receivers - even if it is itself subscribed to the topic it publishes to. You can override that with excludeMe = False.

Regarding RPC (simplified):

You call an endpoint from the client.
You register an endpoint on the server (using registerForRPC).

I suggest you call all your method from the client and provide both a success _and_ error handler like here:

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/rpc/simple/example2/client.py#L57

That way you can be sure you get feedback in both cases (sucess and error).

If you run into problem, you can also turn on debugWamp = True on the WAMP factories (that works both for client and server), like here

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/rpc/simple/example2/client.py#L77

This will allow you to watch WAMP messages flow and it is often a quick way to get going.

Now part 2):

You Arduino code looks fine to me .. that is given pin 13 actually is your LED. I would check that by typing "0" and "1" into the serial port monitor that is built into the Arduino IDE and see if you can manually toggle the LED .. I think I remember it wasnt just for monitoring but also sending stuff.

Another thing that can go wrong: are you using matching baudrate and serial port? If any of those do not match, things will go wrong.

I am also unsure exactly of how pubsub is supposed to work. Once I my
client has subscribed to a topic, will it automatically receive any
messages sent to that topic?

The client needs to be subscribed, and the topic registered for PubSub on the server. Also see my notes on excludeMe above.

It is important to me for another project that I can receive data sent
by the arduino to a python client.

You can do that .. this is what the demo in the repo does. Watch the Youtube video .. or try yourself .. you need to adjust Arduino code etc to your hardware then of course.

All the code is attached. I am using a Ubuntu virutal unix machine.

That will introduce a couple of other things that can go wrong: is the hypervisor (VirtualBox?) forwarding the USB port your Arduino connects to? Etc etc. This wont be easy.

Try running the server on the host, not inside VM. Lot less potential issues.

Btw: curious: what are you working on?

/Tobias

···

Am 05.11.2013 17:20, schrieb Daniel Davies:

Thanks so much for any help.
Dan D

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#3

Hi Tobias,
Thanks so much for your help. I just got back to the project its been a couple of hectic weeks.

There are 2 parts in your system:

  1. WAMP Client === WAMP / WebSocket ===> WAMP Server

  2. WAMP Server === Your Proto / Serial ===> Arduino

It still isn’t behaving quite as I would like it to and I am quite sure that the problem is with part 2) It might have something to do with what you mentioned before in the following.

All the code is attached. I am using a Ubuntu virutal unix machine.

That will introduce a couple of other things that can go wrong: is the hypervisor (VirtualBox?) forwarding the USB port your Arduino connects to? Etc etc. This wont be easy.

All the other things that you mentioned (baud rate etc…) don’t seem to be the problem. Through the virtual machine I am able to connect to the arduino and make it blink using python, but I can’t seem to do it using a WAMP server. The only reason I am using a VM is that I have a windows computer and it gives me too many headaches. I will give it a go on a mac tomorrow. Hopefully I can make it work that way.

I have attached the code again (it hasn’t changed much, I couldn’t really achieve anything without the arduino responding to any commands) , and I’m pretty sure that the issue lies with this method:

@exportRpc(“control-led”)

def controlLed(self, status):

if status:

print “turn on LED”

self.transport.write(‘1’)

log.msg(‘transported’,status)

return(‘for client: transported’,status)

else:

print “turn off LED”

self.transport.write(‘0’)

log.msg(‘transported’,status)

return(‘for client: transported’,status)

and me not using transport correctly, although I did follow your example pretty closely, so I might give it a go on a mac.

Btw: curious: what are you working on?

I am doing a project for my thesis where I am helping to design an Ardustat for testing the characteristics of batteries (cycling potential, capacities etc.) The whole point of using Autobahn is that the serial connection needs to be able to be fired asynchronously. Currently I am using a small node.js script that does the job but I would like to be able to only rely on python for the project.

Thanks so much for your help,

Best,

Dan Davies

serialclient.py (2.75 KB)

serialclient.py (2.75 KB)

serialserver.py (4.59 KB)

···

On Tue, Nov 5, 2013 at 6:24 PM, Tobias Oberstein tobias.o...@gmail.com wrote:

Am 05.11.2013 17:20, schrieb Daniel Davies:

Hi,

I am trying to do a fairly basic communication between an arduino and a

websocket and client. I am sorry for any completely obvious errors or

misunderstandings, I am pretty new to this.

Nothing to apologize. I will try a first round … expect some learning experience;)

I have used and slightly modified the example given on

https://github.com/tavendo/AutobahnPython/tree/master/examples/wamp/serial2ws

That is good! In general, start with an example, assure yourself it works, and only then modify it. That way, you always have a “known good”.

Now with the Arduino stuff the limit with this is of course that any example will depend on concrete hardware. Or is there any hardware that is built into every Arduino? If so, we probably should have an example for that.

My code is supposed to send a simple command from a python client to

make the arduino blink 5 times. I think I am having an issue with the

communication between the server and the arduino as the command seems to

be called properly by the client but no blinking or response is given by

the arduino.

There are 2 parts in your system:

  1. WAMP Client === WAMP / WebSocket ===> WAMP Server

  2. WAMP Server === Your Proto / Serial ===> Arduino

Regarding 1), there is a principle issue with your code: sleep()

AutobahnPython is based Twisted, and this is a asynchronous library which runs under a thing called a “reactor”. There are many good intros on the net, suffice to say: you must not block the reactor.

And sleep(), like other functions form the Python standard library do block. Now it might look like some things work even if you do bad blocking, but it is wrong and will result in all kinds of strange and hard to debug problems. In short: there is no way around getting familiar with the asynchronous programming approach. Like JavaScript in the browser: everything is event driven.

Here is a WAMP client that publishes periodically:

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/pubsub/simple/example1/client.py

It uses reactor.callLater() - and that will not block the reactor.

Regarding PubSub (simplified):

You subscribe and publish from the client.

You register a topic for PubSub on the server.

The “True” argument to registerForPubSub registers not only the specific topic given, but all topics that have the given prefix.

When you publish from a client, that client is by default excluded from the receivers - even if it is itself subscribed to the topic it publishes to. You can override that with excludeMe = False.

Regarding RPC (simplified):

You call an endpoint from the client.

You register an endpoint on the server (using registerForRPC).

I suggest you call all your method from the client and provide both a success and error handler like here:

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/rpc/simple/example2/client.py#L57

That way you can be sure you get feedback in both cases (sucess and error).

If you run into problem, you can also turn on debugWamp = True on the WAMP factories (that works both for client and server), like here

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/rpc/simple/example2/client.py#L77

This will allow you to watch WAMP messages flow and it is often a quick way to get going.

Now part 2):

You Arduino code looks fine to me … that is given pin 13 actually is your LED. I would check that by typing “0” and “1” into the serial port monitor that is built into the Arduino IDE and see if you can manually toggle the LED … I think I remember it wasnt just for monitoring but also sending stuff.

Another thing that can go wrong: are you using matching baudrate and serial port? If any of those do not match, things will go wrong.

I am also unsure exactly of how pubsub is supposed to work. Once I my

client has subscribed to a topic, will it automatically receive any

messages sent to that topic?

The client needs to be subscribed, and the topic registered for PubSub on the server. Also see my notes on excludeMe above.

It is important to me for another project that I can receive data sent

by the arduino to a python client.

You can do that … this is what the demo in the repo does. Watch the Youtube video … or try yourself … you need to adjust Arduino code etc to your hardware then of course.

All the code is attached. I am using a Ubuntu virutal unix machine.

That will introduce a couple of other things that can go wrong: is the hypervisor (VirtualBox?) forwarding the USB port your Arduino connects to? Etc etc. This wont be easy.

Try running the server on the host, not inside VM. Lot less potential issues.

Btw: curious: what are you working on?

/Tobias

Thanks so much for any help.

Dan D

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+unsubscribe@googlegroups.com.

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

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

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

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

0 Likes

#4

Hi Again Tobias,

This part of the project was put on hold again as we tried to make and even simpler device. Anyway, I am back on it and think I have fixed a couple of the problems. I still have some questions that hope you have time to help me with.

I am pretty sure that anything I have to do with pubsub is not going to work right now because I’m fairly sure I have done it wrong. I am going through your examples now and will try my best to fix it myself.

The issue that I need help with right now is the following method.

def simpleblink(self):

print “trying to blink”

i = 0

self.RPCoff

while (i < 5):

reactor.callLater(5, self.RPCon)

reactor.callLater(5, self.RPCoff)

i = i+1

#simple print statement to see when we are going through the loop…

print "i = ", i

print “finished trying to blink”

I am trying to make my aruidno blink 5 times for 5 seconds each time. It seems to me that there is some sort of communication happening because I am able to turn the LED on or off but only once.

It seems to me that the while loop should take about 50 seconds to complete. It seems to go much faster than that. I only receive print statements it seems once all of the transports are completed.

Is this because the code runs straight through the loop and then attempts to call the reactor later? Should I be trying to write the loop so that it only changes based on events? I.e. the arudino LED being on or off?

I have attached the code.

Sorry if you can’t make sense of anything that I’m writing here. I will continue to try and fix it and will try and send a more detailed description of my problem if i can.

Thanks,

Dan Davies

serialclient_wip.py (3.18 KB)

serialserver_wip.py (4.77 KB)

···

On Mon, Nov 18, 2013 at 4:19 PM, Daniel Davies dmda...@princeton.edu wrote:

Hi Tobias,
Thanks so much for your help. I just got back to the project its been a couple of hectic weeks.

There are 2 parts in your system:

  1. WAMP Client === WAMP / WebSocket ===> WAMP Server

  2. WAMP Server === Your Proto / Serial ===> Arduino

It still isn’t behaving quite as I would like it to and I am quite sure that the problem is with part 2) It might have something to do with what you mentioned before in the following.

All the code is attached. I am using a Ubuntu virutal unix machine.

That will introduce a couple of other things that can go wrong: is the hypervisor (VirtualBox?) forwarding the USB port your Arduino connects to? Etc etc. This wont be easy.

All the other things that you mentioned (baud rate etc…) don’t seem to be the problem. Through the virtual machine I am able to connect to the arduino and make it blink using python, but I can’t seem to do it using a WAMP server. The only reason I am using a VM is that I have a windows computer and it gives me too many headaches. I will give it a go on a mac tomorrow. Hopefully I can make it work that way.

I have attached the code again (it hasn’t changed much, I couldn’t really achieve anything without the arduino responding to any commands) , and I’m pretty sure that the issue lies with this method:

@exportRpc(“control-led”)

def controlLed(self, status):

if status:

print “turn on LED”

self.transport.write(‘1’)

log.msg(‘transported’,status)

return(‘for client: transported’,status)

else:

print “turn off LED”

self.transport.write(‘0’)

log.msg(‘transported’,status)

return(‘for client: transported’,status)

and me not using transport correctly, although I did follow your example pretty closely, so I might give it a go on a mac.

Btw: curious: what are you working on?

I am doing a project for my thesis where I am helping to design an Ardustat for testing the characteristics of batteries (cycling potential, capacities etc.) The whole point of using Autobahn is that the serial connection needs to be able to be fired asynchronously. Currently I am using a small node.js script that does the job but I would like to be able to only rely on python for the project.

Thanks so much for your help,

Best,

Dan Davies

On Tue, Nov 5, 2013 at 6:24 PM, Tobias Oberstein tobias.o...@gmail.com wrote:

Am 05.11.2013 17:20, schrieb Daniel Davies:

Hi,

I am trying to do a fairly basic communication between an arduino and a

websocket and client. I am sorry for any completely obvious errors or

misunderstandings, I am pretty new to this.

Nothing to apologize. I will try a first round … expect some learning experience;)

I have used and slightly modified the example given on

https://github.com/tavendo/AutobahnPython/tree/master/examples/wamp/serial2ws

That is good! In general, start with an example, assure yourself it works, and only then modify it. That way, you always have a “known good”.

Now with the Arduino stuff the limit with this is of course that any example will depend on concrete hardware. Or is there any hardware that is built into every Arduino? If so, we probably should have an example for that.

My code is supposed to send a simple command from a python client to

make the arduino blink 5 times. I think I am having an issue with the

communication between the server and the arduino as the command seems to

be called properly by the client but no blinking or response is given by

the arduino.

There are 2 parts in your system:

  1. WAMP Client === WAMP / WebSocket ===> WAMP Server

  2. WAMP Server === Your Proto / Serial ===> Arduino

Regarding 1), there is a principle issue with your code: sleep()

AutobahnPython is based Twisted, and this is a asynchronous library which runs under a thing called a “reactor”. There are many good intros on the net, suffice to say: you must not block the reactor.

And sleep(), like other functions form the Python standard library do block. Now it might look like some things work even if you do bad blocking, but it is wrong and will result in all kinds of strange and hard to debug problems. In short: there is no way around getting familiar with the asynchronous programming approach. Like JavaScript in the browser: everything is event driven.

Here is a WAMP client that publishes periodically:

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/pubsub/simple/example1/client.py

It uses reactor.callLater() - and that will not block the reactor.

Regarding PubSub (simplified):

You subscribe and publish from the client.

You register a topic for PubSub on the server.

The “True” argument to registerForPubSub registers not only the specific topic given, but all topics that have the given prefix.

When you publish from a client, that client is by default excluded from the receivers - even if it is itself subscribed to the topic it publishes to. You can override that with excludeMe = False.

Regarding RPC (simplified):

You call an endpoint from the client.

You register an endpoint on the server (using registerForRPC).

I suggest you call all your method from the client and provide both a success and error handler like here:

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/rpc/simple/example2/client.py#L57

That way you can be sure you get feedback in both cases (sucess and error).

If you run into problem, you can also turn on debugWamp = True on the WAMP factories (that works both for client and server), like here

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/rpc/simple/example2/client.py#L77

This will allow you to watch WAMP messages flow and it is often a quick way to get going.

Now part 2):

You Arduino code looks fine to me … that is given pin 13 actually is your LED. I would check that by typing “0” and “1” into the serial port monitor that is built into the Arduino IDE and see if you can manually toggle the LED … I think I remember it wasnt just for monitoring but also sending stuff.

Another thing that can go wrong: are you using matching baudrate and serial port? If any of those do not match, things will go wrong.

I am also unsure exactly of how pubsub is supposed to work. Once I my

client has subscribed to a topic, will it automatically receive any

messages sent to that topic?

The client needs to be subscribed, and the topic registered for PubSub on the server. Also see my notes on excludeMe above.

It is important to me for another project that I can receive data sent

by the arduino to a python client.

You can do that … this is what the demo in the repo does. Watch the Youtube video … or try yourself … you need to adjust Arduino code etc to your hardware then of course.

All the code is attached. I am using a Ubuntu virutal unix machine.

That will introduce a couple of other things that can go wrong: is the hypervisor (VirtualBox?) forwarding the USB port your Arduino connects to? Etc etc. This wont be easy.

Try running the server on the host, not inside VM. Lot less potential issues.

Btw: curious: what are you working on?

/Tobias

Thanks so much for any help.

Dan D

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+unsubscribe@googlegroups.com.

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

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

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

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

0 Likes

#5

The issue that I need help with right now is the following method.

def simpleblink(self):

    print "trying to blink"

    i = 0

    self.RPCoff

    while (i < 5):

       reactor.callLater(5, self.RPCon)

       reactor.callLater(5, self.RPCoff)

       i = i+1

This won't work as you intend. It'll schedule turning on and off the LED 5 times immediately one after another - after a delay of 5secs.
It'll likely be too fast to see any blinking at all.

I can't give you an intro to Twisted and asynchronous programming, but what you are doing is .. wrong;)

There is a way of doing asynchronous programming which looks (and mostly works) like sequential code.

Try this:

from twisted.internet.defer import Deferred, inlineCallbacks

def sleep(delay):
    d = Deferred()
    reactor.callLater(delay, d.callback, None)
    return d

class YourProtocol:
    @inlineCallbacks
    def simpleblink(self):
       for i in range(5):
          self.RPCon()
          yield sleep(5)
          self.RPCoff()
          yield sleep(5)

This assume your RPCon/off methods are working as advertised ..

Hope that gets you further,

/Tobias

0 Likes

#6

Thanks!
I thought it might be something like that.

I’ll give it a go. I’m guessing I could poke around the twisted website to get an intro on asynchronous programming and twisted. Will let you know how I go shortly.

Dan D

···

On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein tobias.o...@gmail.com wrote:

The issue that I need help with right now is the following method.

def simpleblink(self):

print "trying to blink"



i = 0



self.RPCoff



while (i < 5):



   reactor.callLater(5, self.RPCon)



   reactor.callLater(5, self.RPCoff)



   i = i+1

This won’t work as you intend. It’ll schedule turning on and off the LED 5 times immediately one after another - after a delay of 5secs.

It’ll likely be too fast to see any blinking at all.

I can’t give you an intro to Twisted and asynchronous programming, but what you are doing is … wrong;)

There is a way of doing asynchronous programming which looks (and mostly works) like sequential code.

Try this:

from twisted.internet.defer import Deferred, inlineCallbacks

def sleep(delay):

d = Deferred()

reactor.callLater(delay, d.callback, None)

return d

class YourProtocol:

@inlineCallbacks

def simpleblink(self):

  for i in range(5):

     self.RPCon()

     yield sleep(5)

     self.RPCoff()

     yield sleep(5)

This assume your RPCon/off methods are working as advertised …

Hope that gets you further,

/Tobias

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

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

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

0 Likes

#7

Thanks!
I thought it might be something like that.
I'll give it a go. I'm guessing I could poke around the twisted website

Either https://twistedmatrix.com/trac/wiki/Documentation

or

http://krondo.com/?page_id=1327
http://krondo.com/wp-content/uploads/2009/08/twisted-intro.html

The latter is quite good ..

to get an intro on asynchronous programming and twisted. Will let you
know how I go shortly.

You're welcome!

···

Am 06.01.2014 00:00, schrieb Daniel Davies:

Dan D

On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein > <tobias.o...@gmail.com <mailto:tobias.o...@gmail.com>> wrote:

        The issue that I need help with right now is the following method.

        def simpleblink(self):

             print "trying to blink"

             i = 0

             self.RPCoff

             while (i < 5):

                reactor.callLater(5, self.RPCon)

                reactor.callLater(5, self.RPCoff)

                i = i+1

    This won't work as you intend. It'll schedule turning on and off the
    LED 5 times immediately one after another - after a delay of 5secs.
    It'll likely be too fast to see any blinking at all.

    I can't give you an intro to Twisted and asynchronous programming,
    but what you are doing is .. wrong;)

    There is a way of doing asynchronous programming which looks (and
    mostly works) like sequential code.

    Try this:

    from twisted.internet.defer import Deferred, inlineCallbacks

    def sleep(delay):
        d = Deferred()
        reactor.callLater(delay, d.callback, None)
        return d

    class YourProtocol:
        @inlineCallbacks
        def simpleblink(self):
           for i in range(5):
              self.RPCon()
              yield sleep(5)
              self.RPCoff()
              yield sleep(5)

    This assume your RPCon/off methods are working as advertised ..

    Hope that gets you further,

    /Tobias

    --
    You received this message because you are subscribed to the Google
    Groups "Autobahn" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to autobahnws+unsubscribe@__googlegroups.com
    <mailto:autobahnws%2...@googlegroups.com>.
    For more options, visit https://groups.google.com/__groups/opt_out
    <https://groups.google.com/groups/opt_out>.

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#8

Righto, so i just put this into my protocol class. Doesn’t seem to work as it should, it only seems to call RPCon() and then doesn’t do anything from there.

Will be looking around twisted to try work out how to do it.

Thanks,

Dan D

def sleep(delay):

d = Deferred()

reactor.callLater(delay, d.callback, None)

return d

@inlineCallbacks

def simpleblink(self):

for i in range(5):

self.RPCon()

yield self.sleep(5)

self.RPCoff()

yield self.sleep(5)

···

On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies dmda...@princeton.edu wrote:

Thanks!
I thought it might be something like that.

I’ll give it a go. I’m guessing I could poke around the twisted website to get an intro on asynchronous programming and twisted. Will let you know how I go shortly.

Dan D

On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein tobias.o...@gmail.com wrote:

The issue that I need help with right now is the following method.

def simpleblink(self):

print "trying to blink"



i = 0



self.RPCoff



while (i < 5):



   reactor.callLater(5, self.RPCon)



   reactor.callLater(5, self.RPCoff)



   i = i+1

This won’t work as you intend. It’ll schedule turning on and off the LED 5 times immediately one after another - after a delay of 5secs.

It’ll likely be too fast to see any blinking at all.

I can’t give you an intro to Twisted and asynchronous programming, but what you are doing is … wrong;)

There is a way of doing asynchronous programming which looks (and mostly works) like sequential code.

Try this:

from twisted.internet.defer import Deferred, inlineCallbacks

def sleep(delay):

d = Deferred()

reactor.callLater(delay, d.callback, None)

return d

class YourProtocol:

@inlineCallbacks

def simpleblink(self):

  for i in range(5):

     self.RPCon()

     yield sleep(5)

     self.RPCoff()

     yield sleep(5)

This assume your RPCon/off methods are working as advertised …

Hope that gets you further,

/Tobias

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

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

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

0 Likes

#9

Righto, so i just put this into my protocol class. Doesn't seem to work
as it should, it only seems to call RPCon() and then doesn't do anything
from there.

Well;)

You can try

https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py

from this example

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo

And then debug your code ..

···

Am 06.01.2014 00:22, schrieb Daniel Davies:

Will be looking around twisted to try work out how to do it.

Thanks,

Dan D

def sleep(delay):

d = Deferred()

reactor.callLater(delay, d.callback, None)

return d

@inlineCallbacks

def simpleblink(self):

for i in range(5):

self.RPCon()

yield self.sleep(5)

self.RPCoff()

yield self.sleep(5)

On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies <dmda...@princeton.edu > <mailto:dmda...@princeton.edu>> wrote:

    Thanks!
    I thought it might be something like that.
    I'll give it a go. I'm guessing I could poke around the twisted
    website to get an intro on asynchronous programming and twisted.
    Will let you know how I go shortly.
    Dan D

    On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein > <tobias.o...@gmail.com <mailto:tobias.o...@gmail.com>> wrote:

            The issue that I need help with right now is the following
            method.

            def simpleblink(self):

                 print "trying to blink"

                 i = 0

                 self.RPCoff

                 while (i < 5):

                    reactor.callLater(5, self.RPCon)

                    reactor.callLater(5, self.RPCoff)

                    i = i+1

        This won't work as you intend. It'll schedule turning on and off
        the LED 5 times immediately one after another - after a delay of
        5secs.
        It'll likely be too fast to see any blinking at all.

        I can't give you an intro to Twisted and asynchronous
        programming, but what you are doing is .. wrong;)

        There is a way of doing asynchronous programming which looks
        (and mostly works) like sequential code.

        Try this:

        from twisted.internet.defer import Deferred, inlineCallbacks

        def sleep(delay):
            d = Deferred()
            reactor.callLater(delay, d.callback, None)
            return d

        class YourProtocol:
            @inlineCallbacks
            def simpleblink(self):
               for i in range(5):
                  self.RPCon()
                  yield sleep(5)
                  self.RPCoff()
                  yield sleep(5)

        This assume your RPCon/off methods are working as advertised ..

        Hope that gets you further,

        /Tobias

        --
        You received this message because you are subscribed to the
        Google Groups "Autobahn" group.
        To unsubscribe from this group and stop receiving emails from
        it, send an email to autobahnws+unsubscribe@__googlegroups.com
        <mailto:autobahnws%2...@googlegroups.com>.
        For more options, visit
        https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>.

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#10

Ok thanks!
Might take a little longer but again ill probably be in touch again soon.

Dan D

···

On Mon, Jan 6, 2014 at 12:28 PM, Tobias Oberstein tobias.o...@gmail.com wrote:

Am 06.01.2014 00:22, schrieb Daniel Davies:

Righto, so i just put this into my protocol class. Doesn’t seem to work

as it should, it only seems to call RPCon() and then doesn’t do anything

from there.

Well;)

You can try

https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py

from this example

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo

And then debug your code …

Will be looking around twisted to try work out how to do it.

Thanks,

Dan D

def sleep(delay):

d = Deferred()

reactor.callLater(delay, d.callback, None)

return d

@inlineCallbacks

def simpleblink(self):

for i in range(5):

self.RPCon()

yield self.sleep(5)

self.RPCoff()

yield self.sleep(5)

On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies <dmda…@princeton.edu

mailto:dmda...@princeton.edu> wrote:

Thanks!

I thought it might be something like that.

I'll give it a go. I'm guessing I could poke around the twisted

website to get an intro on asynchronous programming and twisted.

Will let you know how I go shortly.

Dan D





On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein

<tobias.o...@gmail.com mailto:tobias.oberstein@gmail.com> wrote:

        The issue that I need help with right now is the following

        method.



        def simpleblink(self):



             print "trying to blink"



             i = 0



             self.RPCoff



             while (i < 5):



                reactor.callLater(5, self.RPCon)



                reactor.callLater(5, self.RPCoff)



                i = i+1





    This won't work as you intend. It'll schedule turning on and off

    the LED 5 times immediately one after another - after a delay of

    5secs.

    It'll likely be too fast to see any blinking at all.



    I can't give you an intro to Twisted and asynchronous

    programming, but what you are doing is .. wrong;)



    There is a way of doing asynchronous programming which looks

    (and mostly works) like sequential code.



    Try this:



    from twisted.internet.defer import Deferred, inlineCallbacks



    def sleep(delay):

        d = Deferred()

        reactor.callLater(delay, d.callback, None)

        return d



    class YourProtocol:

        @inlineCallbacks

        def simpleblink(self):

           for i in range(5):

              self.RPCon()

              yield sleep(5)

              self.RPCoff()

              yield sleep(5)





    This assume your RPCon/off methods are working as advertised ..



    Hope that gets you further,



    /Tobias





    --

    You received this message because you are subscribed to the

    Google Groups "Autobahn" group.

    To unsubscribe from this group and stop receiving emails from

it, send an email to autobahnws+unsubscribe@__googlegroups.com

    <mailto:autobahnws%2Bunsu...@googlegroups.com>.

    For more options, visit

    [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+unsubscribe@googlegroups.com.

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

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

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

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

0 Likes

#11

Thanks again Tobias.

I’ve got everything pretty much the way wanted it to. Is there a way to communicate with things inside the reactor from outside of it? Or is it more common to do everything inside the reactor?

Dan D

···

On Sun, Jan 5, 2014 at 6:30 PM, Daniel Davies dmda...@princeton.edu wrote:

Ok thanks!
Might take a little longer but again ill probably be in touch again soon.

Dan D

On Mon, Jan 6, 2014 at 12:28 PM, Tobias Oberstein tobias.o...@gmail.com wrote:

Am 06.01.2014 00:22, schrieb Daniel Davies:

Righto, so i just put this into my protocol class. Doesn’t seem to work

as it should, it only seems to call RPCon() and then doesn’t do anything

from there.

Well;)

You can try

https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py

from this example

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo

And then debug your code …

Will be looking around twisted to try work out how to do it.

Thanks,

Dan D

def sleep(delay):

d = Deferred()

reactor.callLater(delay, d.callback, None)

return d

@inlineCallbacks

def simpleblink(self):

for i in range(5):

self.RPCon()

yield self.sleep(5)

self.RPCoff()

yield self.sleep(5)

On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies <dmda…@princeton.edu

mailto:dmda...@princeton.edu> wrote:

Thanks!

I thought it might be something like that.

I'll give it a go. I'm guessing I could poke around the twisted

website to get an intro on asynchronous programming and twisted.

Will let you know how I go shortly.

Dan D





On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein

<tobias.o...@gmail.com mailto:tobias.oberstein@gmail.com> wrote:

        The issue that I need help with right now is the following

        method.



        def simpleblink(self):



             print "trying to blink"



             i = 0



             self.RPCoff



             while (i < 5):



                reactor.callLater(5, self.RPCon)



                reactor.callLater(5, self.RPCoff)



                i = i+1





    This won't work as you intend. It'll schedule turning on and off

    the LED 5 times immediately one after another - after a delay of

    5secs.

    It'll likely be too fast to see any blinking at all.



    I can't give you an intro to Twisted and asynchronous

    programming, but what you are doing is .. wrong;)



    There is a way of doing asynchronous programming which looks

    (and mostly works) like sequential code.



    Try this:



    from twisted.internet.defer import Deferred, inlineCallbacks



    def sleep(delay):

        d = Deferred()

        reactor.callLater(delay, d.callback, None)

        return d



    class YourProtocol:

        @inlineCallbacks

        def simpleblink(self):

           for i in range(5):

              self.RPCon()

              yield sleep(5)

              self.RPCoff()

              yield sleep(5)





    This assume your RPCon/off methods are working as advertised ..



    Hope that gets you further,



    /Tobias





    --

    You received this message because you are subscribed to the

    Google Groups "Autobahn" group.

    To unsubscribe from this group and stop receiving emails from

it, send an email to autobahnws+unsubscribe@__googlegroups.com

    <mailto:autobahnws%2Bunsu...@googlegroups.com>.

    For more options, visit

    [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+unsubscribe@googlegroups.com.

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

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

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

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

0 Likes

#12

Thanks again Tobias.

I've got everything pretty much the way wanted it to. Is there a way to

Great!

communicate with things inside the reactor from outside of it? Or is it
more common to do everything inside the reactor?

Not sure what you mean.

You program will at some point do

reactor.run()

And this function never returns (well, if it does, the only sensible thing is to exit, since you cannot restart the Twisted reactor).

In this sense, everything in your program is run "under the reactor" (since you stuff is triggered from the event loop running in the reactor).

And the reactor runs on the first thread (the main thread) of your Python process.

Now, the exception to this if you use background threads. Either explicitly via deferToThread etc, or implicitly by using twisted.enterprise.adbapi.

The general advice is: write code non-blocking "Twisted style" and run it on the main thread (under the reactor), unless one of the following:

1. You are doing CPU intensive stuff (run that on background thread, otherwise it'll block your networking, and you won't make use of multicore CPUs)

2. You _must_ call some 3rd party _blocking_ code (eg. database drivers etc) - again run on background thread.

Hope this helps,

/Tobias

···

Am 19.01.2014 02:22, schrieb Daniel Davies:

Dan D

On Sun, Jan 5, 2014 at 6:30 PM, Daniel Davies <dmda...@princeton.edu > <mailto:dmda...@princeton.edu>> wrote:

    Ok thanks!
    Might take a little longer but again ill probably be in touch again
    soon.
    Dan D

    On Mon, Jan 6, 2014 at 12:28 PM, Tobias Oberstein > <tobias.o...@gmail.com <mailto:tobias.o...@gmail.com>> wrote:

        Am 06.01.2014 00:22, schrieb Daniel Davies:

            Righto, so i just put this into my protocol class. Doesn't
            seem to work
            as it should, it only seems to call RPCon() and then doesn't
            do anything
            from there.

        Well;)

        You can try

        https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py
        <https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py>

        from this example

        https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo
        <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo>

        And then debug your code ..

            Will be looking around twisted to try work out how to do it.

            Thanks,

            Dan D

            def sleep(delay):

            d = Deferred()

            reactor.callLater(delay, d.callback, None)

            return d

            @inlineCallbacks

            def simpleblink(self):

            for i in range(5):

            self.RPCon()

            yield self.sleep(5)

            self.RPCoff()

            yield self.sleep(5)

            On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies > <dmda...@princeton.edu <mailto:dmda...@princeton.edu> > <mailto:dmda...@princeton.edu > <mailto:dmda...@princeton.edu>__>> wrote:

                 Thanks!
                 I thought it might be something like that.
                 I'll give it a go. I'm guessing I could poke around the
            twisted
                 website to get an intro on asynchronous programming and
            twisted.
                 Will let you know how I go shortly.
                 Dan D

                 On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein > <tobias.o...@gmail.com > <mailto:tobias.o...@gmail.com> > <mailto:tobias.o...@__gmail.com > <mailto:tobias.o...@gmail.com>>> wrote:

                         The issue that I need help with right now is
            the following
                         method.

                         def simpleblink(self):

                              print "trying to blink"

                              i = 0

                              self.RPCoff

                              while (i < 5):

                                 reactor.callLater(5, self.RPCon)

                                 reactor.callLater(5, self.RPCoff)

                                 i = i+1

                     This won't work as you intend. It'll schedule
            turning on and off
                     the LED 5 times immediately one after another -
            after a delay of
                     5secs.
                     It'll likely be too fast to see any blinking at all.

                     I can't give you an intro to Twisted and asynchronous
                     programming, but what you are doing is .. wrong;)

                     There is a way of doing asynchronous programming
            which looks
                     (and mostly works) like sequential code.

                     Try this:

                     from twisted.internet.defer import Deferred,
            inlineCallbacks

                     def sleep(delay):
                         d = Deferred()
                         reactor.callLater(delay, d.callback, None)
                         return d

                     class YourProtocol:
                         @inlineCallbacks
                         def simpleblink(self):
                            for i in range(5):
                               self.RPCon()
                               yield sleep(5)
                               self.RPCoff()
                               yield sleep(5)

                     This assume your RPCon/off methods are working as
            advertised ..

                     Hope that gets you further,

                     /Tobias

                     --
                     You received this message because you are
            subscribed to the
                     Google Groups "Autobahn" group.
                     To unsubscribe from this group and stop receiving
            emails from
                     it, send an email to
            autobahnws+unsubscribe@__googl__egroups.com
            <http://googlegroups.com>
                     <mailto:autobahnws%__...@googlegroups.com
            <mailto:autobahnws%25...@googlegroups.com>__>.
                     For more options, visit
            https://groups.google.com/____groups/opt_out
            <https://groups.google.com/__groups/opt_out>
                     <https://groups.google.com/__groups/opt_out
            <https://groups.google.com/groups/opt_out>>.

            --
            You received this message because you are subscribed to the
            Google
            Groups "Autobahn" group.
            To unsubscribe from this group and stop receiving emails
            from it, send
            an email to autobahnws+unsubscribe@__googlegroups.com
            <mailto:autobahnws%2...@googlegroups.com>.
            For more options, visit
            https://groups.google.com/__groups/opt_out
            <https://groups.google.com/groups/opt_out>.

        --
        You received this message because you are subscribed to the
        Google Groups "Autobahn" group.
        To unsubscribe from this group and stop receiving emails from
        it, send an email to autobahnws+unsubscribe@__googlegroups.com
        <mailto:autobahnws%2...@googlegroups.com>.
        For more options, visit
        https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>.

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#13

Thanks! I just have some code that I use to control the ardustat. Right now, if I put it in the reactor it would definitely block it. I was wondering if it would be easier to leave it outside the reactor or to put it inside and tweak it a little. Sounds like the latter is the best option.
Thanks,

Dan D

···

On Sun, Jan 19, 2014 at 5:12 AM, Tobias Oberstein tobias.o...@gmail.com wrote:

Am 19.01.2014 02:22, schrieb Daniel Davies:

Thanks again Tobias.

I’ve got everything pretty much the way wanted it to. Is there a way to

Great!

communicate with things inside the reactor from outside of it? Or is it

more common to do everything inside the reactor?

Not sure what you mean.

You program will at some point do

reactor.run()

And this function never returns (well, if it does, the only sensible thing is to exit, since you cannot restart the Twisted reactor).

In this sense, everything in your program is run “under the reactor” (since you stuff is triggered from the event loop running in the reactor).

And the reactor runs on the first thread (the main thread) of your Python process.

Now, the exception to this if you use background threads. Either explicitly via deferToThread etc, or implicitly by using twisted.enterprise.adbapi.

The general advice is: write code non-blocking “Twisted style” and run it on the main thread (under the reactor), unless one of the following:

  1. You are doing CPU intensive stuff (run that on background thread, otherwise it’ll block your networking, and you won’t make use of multicore CPUs)

  2. You must call some 3rd party blocking code (eg. database drivers etc) - again run on background thread.

Hope this helps,

/Tobias

Dan D

On Sun, Jan 5, 2014 at 6:30 PM, Daniel Davies <dmda…@princeton.edu

mailto:dmda...@princeton.edu> wrote:

Ok thanks!

Might take a little longer but again ill probably be in touch again

soon.

Dan D





On Mon, Jan 6, 2014 at 12:28 PM, Tobias Oberstein

<tobias.o...@gmail.com mailto:tobias.oberstein@gmail.com> wrote:

    Am 06.01.2014 00:22, schrieb Daniel Davies:



        Righto, so i just put this into my protocol class. Doesn't

        seem to work

        as it should, it only seems to call RPCon() and then doesn't

        do anything

        from there.





    Well;)



    You can try

https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py

    <[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py)>




    from this example

https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo

    <[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo)>




    And then debug your code ..





        Will be looking around twisted to try work out how to do it.



        Thanks,



        Dan D





        def sleep(delay):



        d = Deferred()



        reactor.callLater(delay, d.callback, None)



        return d







        @inlineCallbacks



        def simpleblink(self):



        for i in range(5):



        self.RPCon()



        yield self.sleep(5)



        self.RPCoff()



        yield self.sleep(5)







        On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies

        <dmda...@princeton.edu <mailto:dmda...@princeton.edu>

<mailto:dmda...@princeton.edu

        <mailto:dmda...@princeton.edu>__>> wrote:



             Thanks!

             I thought it might be something like that.

             I'll give it a go. I'm guessing I could poke around the

        twisted

             website to get an intro on asynchronous programming and

        twisted.

             Will let you know how I go shortly.

             Dan D





             On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein

             <tobias.o...@gmail.com

        <mailto:tobias.oberstein@gmail.com>

<mailto:tobias.oberstein@__gmail.com

        <mailto:tobias.oberstein@gmail.com>>> wrote:



                     The issue that I need help with right now is

        the following

                     method.



                     def simpleblink(self):



                          print "trying to blink"



                          i = 0



                          self.RPCoff



                          while (i < 5):



                             reactor.callLater(5, self.RPCon)



                             reactor.callLater(5, self.RPCoff)



                             i = i+1





                 This won't work as you intend. It'll schedule

        turning on and off

                 the LED 5 times immediately one after another -

        after a delay of

                 5secs.

                 It'll likely be too fast to see any blinking at all.



                 I can't give you an intro to Twisted and asynchronous

                 programming, but what you are doing is .. wrong;)



                 There is a way of doing asynchronous programming

        which looks

                 (and mostly works) like sequential code.



                 Try this:



                 from twisted.internet.defer import Deferred,

        inlineCallbacks



                 def sleep(delay):

                     d = Deferred()

                     reactor.callLater(delay, d.callback, None)

                     return d



                 class YourProtocol:

                     @inlineCallbacks

                     def simpleblink(self):

                        for i in range(5):

                           self.RPCon()

                           yield sleep(5)

                           self.RPCoff()

                           yield sleep(5)





                 This assume your RPCon/off methods are working as

        advertised ..



                 Hope that gets you further,



                 /Tobias





                 --

                 You received this message because you are

        subscribed to the

                 Google Groups "Autobahn" group.

                 To unsubscribe from this group and stop receiving

        emails from

                 it, send an email to

autobahnws+unsubscribe@__googl__egroups.com

        <[http://googlegroups.com](http://googlegroups.com)>

                 <mailto:autobahnws%__2Bunsu...@googlegroups.com

        <mailto:autobahnws%252Bunsubscribe@googlegroups.com>__>.

                 For more options, visit

        [https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

        <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>


                 <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

        <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>.









        --

        You received this message because you are subscribed to the

        Google

        Groups "Autobahn" group.

        To unsubscribe from this group and stop receiving emails

        from it, send

        an email to autobahnws+unsubscribe@__[googlegroups.com](http://googlegroups.com)

        <mailto:autobahnws%2Bunsu...@googlegroups.com>.

        For more options, visit

        [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

        <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.





    --

    You received this message because you are subscribed to the

    Google Groups "Autobahn" group.

    To unsubscribe from this group and stop receiving emails from

    it, send an email to autobahnws+unsubscribe@__[googlegroups.com](http://googlegroups.com)

    <mailto:autobahnws%2Bunsu...@googlegroups.com>.

    For more options, visit

    [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+unsubscribe@googlegroups.com.

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

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

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

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

0 Likes

#14

My only problem is that everything inside the reactor runs asynchronously correct? The other code that I have written needs to run synchronously. Is there an easy way to solve this?

···

On Sun, Jan 19, 2014 at 3:56 PM, Daniel Davies dmda...@princeton.edu wrote:

Thanks! I just have some code that I use to control the ardustat. Right now, if I put it in the reactor it would definitely block it. I was wondering if it would be easier to leave it outside the reactor or to put it inside and tweak it a little. Sounds like the latter is the best option.
Thanks,

Dan D

On Sun, Jan 19, 2014 at 5:12 AM, Tobias Oberstein tobias.o...@gmail.com wrote:

Am 19.01.2014 02:22, schrieb Daniel Davies:

Thanks again Tobias.

I’ve got everything pretty much the way wanted it to. Is there a way to

Great!

communicate with things inside the reactor from outside of it? Or is it

more common to do everything inside the reactor?

Not sure what you mean.

You program will at some point do

reactor.run()

And this function never returns (well, if it does, the only sensible thing is to exit, since you cannot restart the Twisted reactor).

In this sense, everything in your program is run “under the reactor” (since you stuff is triggered from the event loop running in the reactor).

And the reactor runs on the first thread (the main thread) of your Python process.

Now, the exception to this if you use background threads. Either explicitly via deferToThread etc, or implicitly by using twisted.enterprise.adbapi.

The general advice is: write code non-blocking “Twisted style” and run it on the main thread (under the reactor), unless one of the following:

  1. You are doing CPU intensive stuff (run that on background thread, otherwise it’ll block your networking, and you won’t make use of multicore CPUs)

  2. You must call some 3rd party blocking code (eg. database drivers etc) - again run on background thread.

Hope this helps,

/Tobias

Dan D

On Sun, Jan 5, 2014 at 6:30 PM, Daniel Davies <dmda…@princeton.edu

mailto:dmda...@princeton.edu> wrote:

Ok thanks!

Might take a little longer but again ill probably be in touch again

soon.

Dan D





On Mon, Jan 6, 2014 at 12:28 PM, Tobias Oberstein

<tobias.o...@gmail.com mailto:tobias.oberstein@gmail.com> wrote:

    Am 06.01.2014 00:22, schrieb Daniel Davies:



        Righto, so i just put this into my protocol class. Doesn't

        seem to work

        as it should, it only seems to call RPCon() and then doesn't

        do anything

        from there.





    Well;)



    You can try

https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py

    <[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py)>





    from this example

https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo

    <[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo)>





    And then debug your code ..





        Will be looking around twisted to try work out how to do it.



        Thanks,



        Dan D





        def sleep(delay):



        d = Deferred()



        reactor.callLater(delay, d.callback, None)



        return d







        @inlineCallbacks



        def simpleblink(self):



        for i in range(5):



        self.RPCon()



        yield self.sleep(5)



        self.RPCoff()



        yield self.sleep(5)







        On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies

        <dmda...@princeton.edu <mailto:dmda...@princeton.edu>

<mailto:dmda...@princeton.edu

        <mailto:dmda...@princeton.edu>__>> wrote:



             Thanks!

             I thought it might be something like that.

             I'll give it a go. I'm guessing I could poke around the

        twisted

             website to get an intro on asynchronous programming and

        twisted.

             Will let you know how I go shortly.

             Dan D





             On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein

             <tobias.o...@gmail.com

        <mailto:tobias.oberstein@gmail.com>

<mailto:tobias.oberstein@__gmail.com

        <mailto:tobias.oberstein@gmail.com>>> wrote:



                     The issue that I need help with right now is

        the following

                     method.



                     def simpleblink(self):



                          print "trying to blink"



                          i = 0



                          self.RPCoff



                          while (i < 5):



                             reactor.callLater(5, self.RPCon)



                             reactor.callLater(5, self.RPCoff)



                             i = i+1





                 This won't work as you intend. It'll schedule

        turning on and off

                 the LED 5 times immediately one after another -

        after a delay of

                 5secs.

                 It'll likely be too fast to see any blinking at all.



                 I can't give you an intro to Twisted and asynchronous

                 programming, but what you are doing is .. wrong;)



                 There is a way of doing asynchronous programming

        which looks

                 (and mostly works) like sequential code.



                 Try this:



                 from twisted.internet.defer import Deferred,

        inlineCallbacks



                 def sleep(delay):

                     d = Deferred()

                     reactor.callLater(delay, d.callback, None)

                     return d



                 class YourProtocol:

                     @inlineCallbacks

                     def simpleblink(self):

                        for i in range(5):

                           self.RPCon()

                           yield sleep(5)

                           self.RPCoff()

                           yield sleep(5)





                 This assume your RPCon/off methods are working as

        advertised ..



                 Hope that gets you further,



                 /Tobias





                 --

                 You received this message because you are

        subscribed to the

                 Google Groups "Autobahn" group.

                 To unsubscribe from this group and stop receiving

        emails from

                 it, send an email to

autobahnws+unsubscribe@__googl__egroups.com

        <[http://googlegroups.com](http://googlegroups.com)>

                 <mailto:autobahnws%__2Bunsu...@googlegroups.com

        <mailto:autobahnws%252Bunsubscribe@googlegroups.com>__>.

                 For more options, visit

        [https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

        <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>


                 <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

        <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>.









        --

        You received this message because you are subscribed to the

        Google

        Groups "Autobahn" group.

        To unsubscribe from this group and stop receiving emails

        from it, send

        an email to autobahnws+unsubscribe@__[googlegroups.com](http://googlegroups.com)

        <mailto:autobahnws%2Bunsu...@googlegroups.com>.

        For more options, visit

        [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

        <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.





    --

    You received this message because you are subscribed to the

    Google Groups "Autobahn" group.

    To unsubscribe from this group and stop receiving emails from

    it, send an email to autobahnws+unsubscribe@__[googlegroups.com](http://googlegroups.com)

    <mailto:autobahnws%2Bunsu...@googlegroups.com>.

    For more options, visit

    [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+unsubscribe@googlegroups.com.

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

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

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

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

0 Likes

#15

If you have code that blocks, this must be run on a background thread:

from twisted.internet.threads import deferToThread

def my_blocking_fun(wsFactory):
    while True:
       data = GPIO.read(..) # this blocks
       ## do something with data, possibly using
       ## wsFactory to notify WS clients:
       reactor.callFromThread(wsFactory.dispatch, data)

deferToThread(my_blocking_fun, myWsFactory)

···

Am 20.01.2014 01:07, schrieb Daniel Davies:

My only problem is that everything inside the reactor runs
asynchronously correct? The other code that I have written needs to run
synchronously. Is there an easy way to solve this?

==

You run your blocking code in a background thread started with "deferToThread", and you communicate with your stuff running on the main thread using "callFromThread" ..

/Tobias

0 Likes

#16

Thanks. I only really wanted to use autobahn for reading and writing calls.
The goal pretty much is.

My_blocking_stuff( ):

readfromautobahn

#dostuff

readfromautobahn

#dostuff

writetoautobahn

readfromautobahn

#dostuff

From what you are saying, it sounds like I can do this with the majority of my code as a background thread. Is this right?

I will give it a go and ask for help if I am still having problems.

Dan D

···

On Mon, Jan 20, 2014 at 6:05 AM, Tobias Oberstein tobias.o...@gmail.com wrote:

Am 20.01.2014 01:07, schrieb Daniel Davies:

My only problem is that everything inside the reactor runs

asynchronously correct? The other code that I have written needs to run

synchronously. Is there an easy way to solve this?

If you have code that blocks, this must be run on a background thread:

from twisted.internet.threads import deferToThread

def my_blocking_fun(wsFactory):

while True:

  data = GPIO.read(..) # this blocks

  ## do something with data, possibly using

  ## wsFactory to notify WS clients:

  reactor.callFromThread(wsFactory.dispatch, data)

deferToThread(my_blocking_fun, myWsFactory)

==

You run your blocking code in a background thread started with “deferToThread”, and you communicate with your stuff running on the main thread using “callFromThread” …

/Tobias

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

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

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

0 Likes

#17

Thanks! I just have some code that I use to control the ardustat. Right

Is it this

https://github.com/dansteingart/Ardustat/

?

If so, this seems to communicate with the host via serial.

And Twisted includes facilities to communicate over serial _without_ blocking and without using background threads. See eg

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/serial2ws

In general, it would help if you could post some code or provide more detail about the code that interfaces with your hardware. That way, we might be able to give you more specific hints ..

/Tobias

···

Am 19.01.2014 21:56, schrieb Daniel Davies:

now, if I put it in the reactor it would definitely block it. I was
wondering if it would be easier to leave it outside the reactor or to
put it inside and tweak it a little. Sounds like the latter is the best
option.
Thanks,
Dan D

On Sun, Jan 19, 2014 at 5:12 AM, Tobias Oberstein > <tobias.o...@gmail.com <mailto:tobias.o...@gmail.com>> wrote:

    Am 19.01.2014 02:22, schrieb Daniel Davies:

        Thanks again Tobias.

        I've got everything pretty much the way wanted it to. Is there a
        way to

    Great!

        communicate with things inside the reactor from outside of it?
        Or is it
        more common to do everything inside the reactor?

    Not sure what you mean.

    You program will at some point do

    reactor.run()

    And this function never returns (well, if it does, the only sensible
    thing is to exit, since you cannot restart the Twisted reactor).

    In this sense, everything in your program is run "under the reactor"
    (since you stuff is triggered from the event loop running in the
    reactor).

    And the reactor runs on the first thread (the main thread) of your
    Python process.

    Now, the exception to this if you use background threads. Either
    explicitly via deferToThread etc, or implicitly by using
    twisted.enterprise.adbapi.

    The general advice is: write code non-blocking "Twisted style" and
    run it on the main thread (under the reactor), unless one of the
    following:

    1. You are doing CPU intensive stuff (run that on background thread,
    otherwise it'll block your networking, and you won't make use of
    multicore CPUs)

    2. You _must_ call some 3rd party _blocking_ code (eg. database
    drivers etc) - again run on background thread.

    Hope this helps,

    /Tobias

        Dan D

        On Sun, Jan 5, 2014 at 6:30 PM, Daniel Davies > <dmda...@princeton.edu <mailto:dmda...@princeton.edu> > <mailto:dmda...@princeton.edu > <mailto:dmda...@princeton.edu>__>> wrote:

             Ok thanks!
             Might take a little longer but again ill probably be in
        touch again
             soon.
             Dan D

             On Mon, Jan 6, 2014 at 12:28 PM, Tobias Oberstein > <tobias.o...@gmail.com > <mailto:tobias.o...@gmail.com> > <mailto:tobias.o...@__gmail.com > <mailto:tobias.o...@gmail.com>>> wrote:

                 Am 06.01.2014 00:22, schrieb Daniel Davies:

                     Righto, so i just put this into my protocol class.
        Doesn't
                     seem to work
                     as it should, it only seems to call RPCon() and
        then doesn't
                     do anything
                     from there.

                 Well;)

                 You can try

        https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py
        <https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py>

        <https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py
        <https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py>>

                 from this example

        https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo
        <https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo>

        <https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo
        <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo>>

                 And then debug your code ..

                     Will be looking around twisted to try work out how
        to do it.

                     Thanks,

                     Dan D

                     def sleep(delay):

                     d = Deferred()

                     reactor.callLater(delay, d.callback, None)

                     return d

                     @inlineCallbacks

                     def simpleblink(self):

                     for i in range(5):

                     self.RPCon()

                     yield self.sleep(5)

                     self.RPCoff()

                     yield self.sleep(5)

                     On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies
                     <dmda...@princeton.edu
        <mailto:dmda...@princeton.edu> <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>__>
                     <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>

                     <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>__>__>> wrote:

                          Thanks!
                          I thought it might be something like that.
                          I'll give it a go. I'm guessing I could poke
        around the
                     twisted
                          website to get an intro on asynchronous
        programming and
                     twisted.
                          Will let you know how I go shortly.
                          Dan D

                          On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein
                          <tobias.o...@gmail.com
        <mailto:tobias.o...@gmail.com>
                     <mailto:tobias.o...@__gmail.com
        <mailto:tobias.o...@gmail.com>>
                     <mailto:tobias.o...@
        <mailto:tobias.o...@>__gma__il.com <http://gmail.com>

                     <mailto:tobias.o...@__gmail.com
        <mailto:tobias.o...@gmail.com>>>> wrote:

                                  The issue that I need help with right
        now is
                     the following
                                  method.

                                  def simpleblink(self):

                                       print "trying to blink"

                                       i = 0

                                       self.RPCoff

                                       while (i < 5):

                                          reactor.callLater(5, self.RPCon)

                                          reactor.callLater(5, self.RPCoff)

                                          i = i+1

                              This won't work as you intend. It'll schedule
                     turning on and off
                              the LED 5 times immediately one after
        another -
                     after a delay of
                              5secs.
                              It'll likely be too fast to see any
        blinking at all.

                              I can't give you an intro to Twisted and
        asynchronous
                              programming, but what you are doing is ..
        wrong;)

                              There is a way of doing asynchronous
        programming
                     which looks
                              (and mostly works) like sequential code.

                              Try this:

                              from twisted.internet.defer import Deferred,
                     inlineCallbacks

                              def sleep(delay):
                                  d = Deferred()
                                  reactor.callLater(delay, d.callback, None)
                                  return d

                              class YourProtocol:
                                  @inlineCallbacks
                                  def simpleblink(self):
                                     for i in range(5):
                                        self.RPCon()
                                        yield sleep(5)
                                        self.RPCoff()
                                        yield sleep(5)

                              This assume your RPCon/off methods are
        working as
                     advertised ..

                              Hope that gets you further,

                              /Tobias

                              --
                              You received this message because you are
                     subscribed to the
                              Google Groups "Autobahn" group.
                              To unsubscribe from this group and stop
        receiving
                     emails from
                              it, send an email to
                     autobahnws+unsubscribe@__googl____egroups.com
        <http://googl__egroups.com>
                     <http://googlegroups.com>

          <mailto:autobahnws%___...@googlegroups.com
        <mailto:autobahnws%25_...@googlegroups.com>

        <mailto:autobahnws%__2...@googlegroups.__com
        <mailto:autobahnws%252...@googlegroups.com>>__>.
                              For more options, visit
        https://groups.google.com/______groups/opt_out
        <https://groups.google.com/____groups/opt_out>
                     <https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>>

          <https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>
                     <https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>>>.

                     --
                     You received this message because you are
        subscribed to the
                     Google
                     Groups "Autobahn" group.
                     To unsubscribe from this group and stop receiving
        emails
                     from it, send
                     an email to
        autobahnws+unsubscribe@__googl__egroups.com
        <http://googlegroups.com>
                     <mailto:autobahnws%__...@googlegroups.com
        <mailto:autobahnws%25...@googlegroups.com>__>.
                     For more options, visit
        https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>
                     <https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>>.

                 --
                 You received this message because you are subscribed to the
                 Google Groups "Autobahn" group.
                 To unsubscribe from this group and stop receiving
        emails from
                 it, send an email to
        autobahnws+unsubscribe@__googl__egroups.com
        <http://googlegroups.com>
                 <mailto:autobahnws%__...@googlegroups.com
        <mailto:autobahnws%25...@googlegroups.com>__>.
                 For more options, visit
        https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>
                 <https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>>.

        --
        You received this message because you are subscribed to the Google
        Groups "Autobahn" group.
        To unsubscribe from this group and stop receiving emails from
        it, send
        an email to autobahnws+unsubscribe@__googlegroups.com
        <mailto:autobahnws%2...@googlegroups.com>.
        For more options, visit
        https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>.

    --
    You received this message because you are subscribed to the Google
    Groups "Autobahn" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to autobahnws+unsubscribe@__googlegroups.com
    <mailto:autobahnws%2...@googlegroups.com>.
    For more options, visit https://groups.google.com/__groups/opt_out
    <https://groups.google.com/groups/opt_out>.

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#18

Thanks!
Yeah, its that. I’m helping Dan rewrite a lot of the code and do some other things for my thesis. (I’m a mechancial engineer so the coding is pretty new to me). I am also curious, because he might be trying to sell it later, are there any copyright rules or issues with asking for your help? I wouldn’t have thought that there would be but I just wanted to check.

···

On Wed, Jan 22, 2014 at 4:20 AM, Tobias Oberstein tobias.o...@gmail.com wrote:

Am 19.01.2014 21:56, schrieb Daniel Davies:

Thanks! I just have some code that I use to control the ardustat. Right

Is it this

https://github.com/dansteingart/Ardustat/

?

If so, this seems to communicate with the host via serial.

And Twisted includes facilities to communicate over serial without blocking and without using background threads. See eg

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/serial2ws

In general, it would help if you could post some code or provide more detail about the code that interfaces with your hardware. That way, we might be able to give you more specific hints …

/Tobias

now, if I put it in the reactor it would definitely block it. I was

wondering if it would be easier to leave it outside the reactor or to

put it inside and tweak it a little. Sounds like the latter is the best

option.

Thanks,

Dan D

On Sun, Jan 19, 2014 at 5:12 AM, Tobias Oberstein

<tobias.o...@gmail.com mailto:tobias.oberstein@gmail.com> wrote:

Am 19.01.2014 02:22, schrieb Daniel Davies:



    Thanks again Tobias.



    I've got everything pretty much the way wanted it to. Is there a

    way to





Great!





    communicate with things inside the reactor from outside of it?

    Or is it

    more common to do everything inside the reactor?





Not sure what you mean.



You program will at some point do



reactor.run()



And this function never returns (well, if it does, the only sensible

thing is to exit, since you cannot restart the Twisted reactor).



In this sense, everything in your program is run "under the reactor"

(since you stuff is triggered from the event loop running in the

reactor).



And the reactor runs on the first thread (the main thread) of your

Python process.



Now, the exception to this if you use background threads. Either

explicitly via deferToThread etc, or implicitly by using

twisted.enterprise.adbapi.



The general advice is: write code non-blocking "Twisted style" and

run it on the main thread (under the reactor), unless one of the

following:



1. You are doing CPU intensive stuff (run that on background thread,

otherwise it'll block your networking, and you won't make use of

multicore CPUs)



2. You _must_ call some 3rd party _blocking_ code (eg. database

drivers etc) - again run on background thread.



Hope this helps,



/Tobias







    Dan D





    On Sun, Jan 5, 2014 at 6:30 PM, Daniel Davies

    <dmda...@princeton.edu <mailto:dmda...@princeton.edu>

<mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>__>> wrote:

Ok thanks!

         Might take a little longer but again ill probably be in

    touch again

         soon.

         Dan D





         On Mon, Jan 6, 2014 at 12:28 PM, Tobias Oberstein

         <tobias.o...@gmail.com

    <mailto:tobias.oberstein@gmail.com>

<mailto:tobias.oberstein@__gmail.com

    <mailto:tobias.oberstein@gmail.com>>> wrote:

Am 06.01.2014 00:22, schrieb Daniel Davies:

                 Righto, so i just put this into my protocol class.

    Doesn't

                 seem to work

                 as it should, it only seems to call RPCon() and

    then doesn't

                 do anything

                 from there.





             Well;)



             You can try

https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py

    <[https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py](https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py)>






    <[https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py](https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py)


    <[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py)>>




             from this example

https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo

    <[https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo](https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo)>






    <[https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo](https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo)


    <[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo)>>




             And then debug your code ..





                 Will be looking around twisted to try work out how

    to do it.



                 Thanks,



                 Dan D





                 def sleep(delay):



                 d = Deferred()



                 reactor.callLater(delay, d.callback, None)



                 return d







                 @inlineCallbacks



                 def simpleblink(self):



                 for i in range(5):



                 self.RPCon()



                 yield self.sleep(5)



                 self.RPCoff()



                 yield self.sleep(5)







                 On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies

                 <dmda...@princeton.edu

    <mailto:dmda...@princeton.edu> <mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>__>

                 <mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>



                 <mailto:dmda...@princeton.edu

mailto:dmda...@princeton.edu>>> wrote:

                      Thanks!

                      I thought it might be something like that.

                      I'll give it a go. I'm guessing I could poke

    around the

                 twisted

                      website to get an intro on asynchronous

    programming and

                 twisted.

                      Will let you know how I go shortly.

                      Dan D





                      On Mon, Jan 6, 2014 at 11:47 AM, Tobias Oberstein

                      <tobias.o...@gmail.com

    <mailto:tobias.oberstein@gmail.com>

                 <mailto:tobias.oberstein@__[gmail.com](http://gmail.com)

    <mailto:tobias.oberstein@gmail.com>>

<mailto:tobias.oberstein@

    <mailto:tobias.oberstein@>__[gma__il.com](http://gma__il.com) <[http://gmail.com](http://gmail.com)>




                 <mailto:tobias.oberstein@__[gmail.com](http://gmail.com)

    <mailto:tobias.oberstein@gmail.com>>>> wrote:



                              The issue that I need help with right

    now is

                 the following

                              method.



                              def simpleblink(self):



                                   print "trying to blink"



                                   i = 0



                                   self.RPCoff



                                   while (i < 5):



                                      reactor.callLater(5, self.RPCon)



                                      reactor.callLater(5, self.RPCoff)



                                      i = i+1





                          This won't work as you intend. It'll schedule

                 turning on and off

                          the LED 5 times immediately one after

    another -

                 after a delay of

                          5secs.

                          It'll likely be too fast to see any

    blinking at all.



                          I can't give you an intro to Twisted and

    asynchronous

                          programming, but what you are doing is ..

    wrong;)



                          There is a way of doing asynchronous

    programming

                 which looks

                          (and mostly works) like sequential code.



                          Try this:



                          from twisted.internet.defer import Deferred,

                 inlineCallbacks



                          def sleep(delay):

                              d = Deferred()

                              reactor.callLater(delay, d.callback, None)

                              return d



                          class YourProtocol:

                              @inlineCallbacks

                              def simpleblink(self):

                                 for i in range(5):

                                    self.RPCon()

                                    yield sleep(5)

                                    self.RPCoff()

                                    yield sleep(5)





                          This assume your RPCon/off methods are

    working as

                 advertised ..



                          Hope that gets you further,



                          /Tobias





                          --

                          You received this message because you are

                 subscribed to the

                          Google Groups "Autobahn" group.

                          To unsubscribe from this group and stop

    receiving

                 emails from

                          it, send an email to

autobahnws+unsubscribe@__googl____egroups.com

    <[http://googl__egroups.com](http://googl__egroups.com)>

                 <[http://googlegroups.com](http://googlegroups.com)>



      <mailto:autobahnws%____2Bunsu...@googlegroups.com

    <mailto:autobahnws%25__2Bunsu...@googlegroups.com>



    <mailto:autobahnws%__252Bunsubscribe@googlegroups.__com

    <mailto:autobahnws%25252Bunsubscribe@googlegroups.com>>__>.

                          For more options, visit

    [https://groups.google.com/______groups/opt_out](https://groups.google.com/______groups/opt_out)

    <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)>


                 <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>>





      <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>

                 <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>>.









                 --

                 You received this message because you are

    subscribed to the

                 Google

                 Groups "Autobahn" group.

                 To unsubscribe from this group and stop receiving

    emails

                 from it, send

                 an email to

    autobahnws+unsubscribe@__[googl__egroups.com](http://googl__egroups.com)

    <[http://googlegroups.com](http://googlegroups.com)>

                 <mailto:autobahnws%__2Bunsu...@googlegroups.com

    <mailto:autobahnws%252Bunsubscribe@googlegroups.com>__>.

                 For more options, visit

    [https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>

                 <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>.





             --

             You received this message because you are subscribed to the

             Google Groups "Autobahn" group.

             To unsubscribe from this group and stop receiving

    emails from

             it, send an email to

    autobahnws+unsubscribe@__[googl__egroups.com](http://googl__egroups.com)

    <[http://googlegroups.com](http://googlegroups.com)>

             <mailto:autobahnws%__2Bunsu...@googlegroups.com

    <mailto:autobahnws%252Bunsubscribe@googlegroups.com>__>.

             For more options, visit

    [https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>

             <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>.







    --

    You received this message because you are subscribed to the Google

    Groups "Autobahn" group.

    To unsubscribe from this group and stop receiving emails from

    it, send

    an email to autobahnws+unsubscribe@__[googlegroups.com](http://googlegroups.com)

    <mailto:autobahnws%2Bunsu...@googlegroups.com>.

    For more options, visit

    [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.





--

You received this message because you are subscribed to the Google

Groups "Autobahn" group.

To unsubscribe from this group and stop receiving emails from it,

send an email to autobahnws+unsubscribe@__[googlegroups.com](http://googlegroups.com)

<mailto:autobahnws%2Bunsu...@googlegroups.com>.

For more options, visit [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

<[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+unsubscribe@googlegroups.com.

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

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

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

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

0 Likes

#19

Thanks!
Yeah, its that. I'm helping Dan rewrite a lot of the code and do some

Then there is no need for background threads. I'd suggest you read into the example

https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/wamp/__serial2ws

This will allow you to talk to your hardware over serial on one leg, and WebSocket over the other leg - and all in a non-blocking, non-threaded, sane way.

other things for my thesis. (I'm a mechancial engineer so the coding is
pretty new to me). I am also curious, because he might be trying to sell
it later, are there any copyright rules or issues with asking for your
help? I wouldn't have thought that there would be but I just wanted to
check.

You mean code snippets that I post here in answer trying to help out?

Don't worry: use as you like .. consider those snippets here in my answers to you "public domain". Use as you like (but don't sue me;)

Regarding Autobahn|Python library and example code in the GitHub repository: those have copyright headers and are licensed under Apache 2.0. But this is a "liberal" license, so you can use those in commercial closed source software also. You need to comply with Apache 2.0 nevertheless, e.g. the Autobahn copyright headers need to be retained (appending you copyright headers) - please read the Apache license.

Overall: don't worry;)

/Tobias

···

Am 24.01.2014 04:30, schrieb Daniel Davies:

On Wed, Jan 22, 2014 at 4:20 AM, Tobias Oberstein > <tobias.o...@gmail.com <mailto:tobias.o...@gmail.com>> wrote:

    Am 19.01.2014 21:56, schrieb Daniel Davies:

        Thanks! I just have some code that I use to control the
        ardustat. Right

    Is it this

    https://github.com/__dansteingart/Ardustat/
    <https://github.com/dansteingart/Ardustat/>

    ?

    If so, this seems to communicate with the host via serial.

    And Twisted includes facilities to communicate over serial _without_
    blocking and without using background threads. See eg

    https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/wamp/__serial2ws
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/serial2ws>

    In general, it would help if you could post some code or provide
    more detail about the code that interfaces with your hardware. That
    way, we might be able to give you more specific hints ..

    /Tobias

        now, if I put it in the reactor it would definitely block it. I was
        wondering if it would be easier to leave it outside the reactor
        or to
        put it inside and tweak it a little. Sounds like the latter is
        the best
        option.
        Thanks,
        Dan D

        On Sun, Jan 19, 2014 at 5:12 AM, Tobias Oberstein > <tobias.o...@gmail.com <mailto:tobias.o...@gmail.com> > <mailto:tobias.o...@__gmail.com > <mailto:tobias.o...@gmail.com>>> wrote:

             Am 19.01.2014 02:22, schrieb Daniel Davies:

                 Thanks again Tobias.

                 I've got everything pretty much the way wanted it to.
        Is there a
                 way to

             Great!

                 communicate with things inside the reactor from outside
        of it?
                 Or is it
                 more common to do everything inside the reactor?

             Not sure what you mean.

             You program will at some point do

             reactor.run()

             And this function never returns (well, if it does, the only
        sensible
             thing is to exit, since you cannot restart the Twisted
        reactor).

             In this sense, everything in your program is run "under the
        reactor"
             (since you stuff is triggered from the event loop running
        in the
             reactor).

             And the reactor runs on the first thread (the main thread)
        of your
             Python process.

             Now, the exception to this if you use background threads.
        Either
             explicitly via deferToThread etc, or implicitly by using
             twisted.enterprise.adbapi.

             The general advice is: write code non-blocking "Twisted
        style" and
             run it on the main thread (under the reactor), unless one
        of the
             following:

             1. You are doing CPU intensive stuff (run that on
        background thread,
             otherwise it'll block your networking, and you won't make
        use of
             multicore CPUs)

             2. You _must_ call some 3rd party _blocking_ code (eg. database
             drivers etc) - again run on background thread.

             Hope this helps,

             /Tobias

                 Dan D

                 On Sun, Jan 5, 2014 at 6:30 PM, Daniel Davies
                 <dmda...@princeton.edu <mailto:dmda...@princeton.edu>
        <mailto:dmda...@princeton.edu <mailto:dmda...@princeton.edu>__>
                 <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>
                 <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>__>__>> wrote:

                      Ok thanks!
                      Might take a little longer but again ill probably
        be in
                 touch again
                      soon.
                      Dan D

                      On Mon, Jan 6, 2014 at 12:28 PM, Tobias Oberstein
                      <tobias.o...@gmail.com
        <mailto:tobias.o...@gmail.com>
                 <mailto:tobias.o...@__gmail.com
        <mailto:tobias.o...@gmail.com>>
                 <mailto:tobias.o...@
        <mailto:tobias.o...@>__gma__il.com <http://gmail.com>
                 <mailto:tobias.o...@__gmail.com
        <mailto:tobias.o...@gmail.com>>>> wrote:

                          Am 06.01.2014 00:22, schrieb Daniel Davies:

                              Righto, so i just put this into my
        protocol class.
                 Doesn't
                              seem to work
                              as it should, it only seems to call
        RPCon() and
                 then doesn't
                              do anything
                              from there.

                          Well;)

                          You can try

        https://github.com/tavendo/______AutobahnPython/blob/master/______examples/twisted/websocket/______echo/client_coroutines.py
        <https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py>

        <https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py
        <https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py>>

        <https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py
        <https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py>

        <https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py
        <https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py>>>

                          from this example

        https://github.com/tavendo/______AutobahnPython/tree/master/______examples/twisted/websocket/______echo
        <https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo>

        <https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo
        <https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo>>

        <https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo
        <https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo>

        <https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo
        <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo>>>

                          And then debug your code ..

                              Will be looking around twisted to try work
        out how
                 to do it.

                              Thanks,

                              Dan D

                              def sleep(delay):

                              d = Deferred()

                              reactor.callLater(delay, d.callback, None)

                              return d

                              @inlineCallbacks

                              def simpleblink(self):

                              for i in range(5):

                              self.RPCon()

                              yield self.sleep(5)

                              self.RPCoff()

                              yield self.sleep(5)

                              On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies
                              <dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>
                 <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>__>
        <mailto:dmda...@princeton.edu <mailto:dmda...@princeton.edu>
                 <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>__>__>
                              <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>
                 <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>__>

                              <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>
                 <mailto:dmda...@princeton.edu
        <mailto:dmda...@princeton.edu>__>__>__>> wrote:

                                   Thanks!
                                   I thought it might be something like
        that.
                                   I'll give it a go. I'm guessing I
        could poke
                 around the
                              twisted
                                   website to get an intro on asynchronous
                 programming and
                              twisted.
                                   Will let you know how I go shortly.
                                   Dan D

                                   On Mon, Jan 6, 2014 at 11:47 AM,
        Tobias Oberstein
                                   <tobias.o...@gmail.com
        <mailto:tobias.o...@gmail.com>
                 <mailto:tobias.o...@__gmail.com
        <mailto:tobias.o...@gmail.com>>
                              <mailto:tobias.o...@
        <mailto:tobias.o...@>__gma__il.com <http://gmail.com>
                 <mailto:tobias.o...@__gmail.com
        <mailto:tobias.o...@gmail.com>>>
                              <mailto:tobias.o...@
        <mailto:tobias.o...@>
                 <mailto:tobias.o...@
        <mailto:tobias.o...@>>__gm__a__il.com <http://gma__il.com>
        <http://gmail.com>

                              <mailto:tobias.o...@
        <mailto:tobias.o...@>__gma__il.com <http://gmail.com>
                 <mailto:tobias.o...@__gmail.com
        <mailto:tobias.o...@gmail.com>>>>> wrote:

                                           The issue that I need help
        with right
                 now is
                              the following
                                           method.

                                           def simpleblink(self):

                                                print "trying to blink"

                                                i = 0

                                                self.RPCoff

                                                while (i < 5):

                                                   reactor.callLater(5,
        self.RPCon)

                                                   reactor.callLater(5,
        self.RPCoff)

                                                   i = i+1

                                       This won't work as you intend.
        It'll schedule
                              turning on and off
                                       the LED 5 times immediately one after
                 another -
                              after a delay of
                                       5secs.
                                       It'll likely be too fast to see any
                 blinking at all.

                                       I can't give you an intro to
        Twisted and
                 asynchronous
                                       programming, but what you are
        doing is ..
                 wrong;)

                                       There is a way of doing asynchronous
                 programming
                              which looks
                                       (and mostly works) like
        sequential code.

                                       Try this:

                                       from twisted.internet.defer
        import Deferred,
                              inlineCallbacks

                                       def sleep(delay):
                                           d = Deferred()
                                           reactor.callLater(delay,
        d.callback, None)
                                           return d

                                       class YourProtocol:
                                           @inlineCallbacks
                                           def simpleblink(self):
                                              for i in range(5):
                                                 self.RPCon()
                                                 yield sleep(5)
                                                 self.RPCoff()
                                                 yield sleep(5)

                                       This assume your RPCon/off
        methods are
                 working as
                              advertised ..

                                       Hope that gets you further,

                                       /Tobias

                                       --
                                       You received this message because
        you are
                              subscribed to the
                                       Google Groups "Autobahn" group.
                                       To unsubscribe from this group
        and stop
                 receiving
                              emails from
                                       it, send an email to

          autobahnws+unsubscribe@__googl______egroups.com
        <http://googl____egroups.com>
                 <http://googl__egroups.com>
                              <http://googlegroups.com>

        <mailto:autobahnws%____...@googlegroups.com
        <mailto:autobahnws%25__...@googlegroups.com>
                 <mailto:autobahnws%25__...@googlegroups.com
        <mailto:autobahnws%2525...@googlegroups.com>__>

                 <mailto:autobahnws%____...@googlegroups.
        <mailto:autobahnws%25__...@googlegroups.>____com

        <mailto:autobahnws%__25...@__googlegroups.com
        <mailto:autobahnws%2525...@googlegroups.com>>>__>.
                                       For more options, visit
        https://groups.google.com/________groups/opt_out
        <https://groups.google.com/______groups/opt_out>
                 <https://groups.google.com/______groups/opt_out
        <https://groups.google.com/____groups/opt_out>>

          <https://groups.google.com/______groups/opt_out
        <https://groups.google.com/____groups/opt_out>
                 <https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>>>

                   <https://groups.google.com/______groups/opt_out
        <https://groups.google.com/____groups/opt_out>
                 <https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>>

          <https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>
                 <https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>>>>.

                              --
                              You received this message because you are
                 subscribed to the
                              Google
                              Groups "Autobahn" group.
                              To unsubscribe from this group and stop
        receiving
                 emails
                              from it, send
                              an email to
                 autobahnws+unsubscribe@__googl____egroups.com
        <http://googl__egroups.com>
                 <http://googlegroups.com>

          <mailto:autobahnws%___...@googlegroups.com
        <mailto:autobahnws%25_...@googlegroups.com>
                 <mailto:autobahnws%__2...@googlegroups.__com
        <mailto:autobahnws%252...@googlegroups.com>>__>.
                              For more options, visit
        https://groups.google.com/______groups/opt_out
        <https://groups.google.com/____groups/opt_out>
                 <https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>>

          <https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>
                 <https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>>>.

                          --
                          You received this message because you are
        subscribed to the
                          Google Groups "Autobahn" group.
                          To unsubscribe from this group and stop receiving
                 emails from
                          it, send an email to
                 autobahnws+unsubscribe@__googl____egroups.com
        <http://googl__egroups.com>
                 <http://googlegroups.com>

          <mailto:autobahnws%___...@googlegroups.com
        <mailto:autobahnws%25_...@googlegroups.com>
                 <mailto:autobahnws%__2...@googlegroups.__com
        <mailto:autobahnws%252...@googlegroups.com>>__>.
                          For more options, visit
        https://groups.google.com/______groups/opt_out
        <https://groups.google.com/____groups/opt_out>
                 <https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>>
                          <https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>
                 <https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>>>.

                 --
                 You received this message because you are subscribed to
        the Google
                 Groups "Autobahn" group.
                 To unsubscribe from this group and stop receiving
        emails from
                 it, send
                 an email to autobahnws+unsubscribe@__googl__egroups.com
        <http://googlegroups.com>
                 <mailto:autobahnws%__...@googlegroups.com
        <mailto:autobahnws%25...@googlegroups.com>__>.
                 For more options, visit
        https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>
                 <https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>>.

             --
             You received this message because you are subscribed to the
        Google
             Groups "Autobahn" group.
             To unsubscribe from this group and stop receiving emails
        from it,
             send an email to
        autobahnws+unsubscribe@__googl__egroups.com
        <http://googlegroups.com>
             <mailto:autobahnws%__...@googlegroups.com
        <mailto:autobahnws%25...@googlegroups.com>__>.
             For more options, visit
        https://groups.google.com/____groups/opt_out
        <https://groups.google.com/__groups/opt_out>
             <https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>>.

        --
        You received this message because you are subscribed to the Google
        Groups "Autobahn" group.
        To unsubscribe from this group and stop receiving emails from
        it, send
        an email to autobahnws+unsubscribe@__googlegroups.com
        <mailto:autobahnws%2...@googlegroups.com>.
        For more options, visit
        https://groups.google.com/__groups/opt_out
        <https://groups.google.com/groups/opt_out>.

    --
    You received this message because you are subscribed to the Google
    Groups "Autobahn" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to autobahnws+unsubscribe@__googlegroups.com
    <mailto:autobahnws%2...@googlegroups.com>.
    For more options, visit https://groups.google.com/__groups/opt_out
    <https://groups.google.com/groups/opt_out>.

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#20

Hi Tobias,

I orginally started with the example you recommended, and I’m pretty sure I did that correctly. I fear I may have over complicated the situation now. Currently I am able to do the following communication easily.

  1. WAMP Client === WAMP / WebSocket ===> WAMP Server

  2. WAMP Server === Your Proto / Serial ===> Arduino

You explained this to me earlier in another email. What I am trying to do (and I’m not sure its necessary) is to put another layer of communication in.

  1. WAMP Client ==> MyCode

  2. MyCode ==> WAMP Client

This is because I don’t want to have to write MyCode so that it works inside of the twisted reactor. What I want is to be able to call a method e.g. WRITE(“somestring”) from MyCode that calls a method in the WAMP Client that sends “somestring” through the websocket and server to the Arduino.

I also want to be able to write to MyCode any outputs from the arduino. I am able to do this though using the PubSub methods and deferreds. Ie. I think I can do 3)

So pretty much what I am asking is if it is possible to call a function that is inside the reactor from outside the reactor.

I have attached my code with some comments inside it. Currently the error I am receiving is that the “instance of PubSubClient1 has no attribute calls” - this makes a little bit of sense to me as I figured I would run into problems creating an instance of PubSubClient1 but I thought it was worth a go. Note: To do a read on the arduino I need to write “s0000” to it.

I realize that this may be a very strange way to go about this. I am wondering 1) is it possible to do what I am trying to do? i.e. call methods in the reactor from outside the reactor. and 2) if this is a completely ridiculous way to go about it and I should try something else?

Sorry for the long email and the bunch of code.

I really appreciate all the help you have given me so far.

Thanks,

Dan D

serialclient_compiled1.py (3.2 KB)

serialserver_wip.py (5.54 KB)

···

On Fri, Jan 24, 2014 at 4:32 AM, Tobias Oberstein tobias.o...@gmail.com wrote:

Am 24.01.2014 04:30, schrieb Daniel Davies:

Thanks!

Yeah, its that. I’m helping Dan rewrite a lot of the code and do some

Then there is no need for background threads. I’d suggest you read into the example

https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/wamp/__serial2ws

This will allow you to talk to your hardware over serial on one leg, and WebSocket over the other leg - and all in a non-blocking, non-threaded, sane way.

other things for my thesis. (I’m a mechancial engineer so the coding is

pretty new to me). I am also curious, because he might be trying to sell

it later, are there any copyright rules or issues with asking for your

help? I wouldn’t have thought that there would be but I just wanted to

check.

You mean code snippets that I post here in answer trying to help out?

Don’t worry: use as you like … consider those snippets here in my answers to you “public domain”. Use as you like (but don’t sue me;)

Regarding Autobahn|Python library and example code in the GitHub repository: those have copyright headers and are licensed under Apache 2.0. But this is a “liberal” license, so you can use those in commercial closed source software also. You need to comply with Apache 2.0 nevertheless, e.g. the Autobahn copyright headers need to be retained (appending you copyright headers) - please read the Apache license.

Overall: don’t worry;)

/Tobias

On Wed, Jan 22, 2014 at 4:20 AM, Tobias Oberstein

<tobias.o...@gmail.com mailto:tobias.oberstein@gmail.com> wrote:

Am 19.01.2014 21:56, schrieb Daniel Davies:



    Thanks! I just have some code that I use to control the

    ardustat. Right





Is it this

https://github.com/__dansteingart/Ardustat/

<[https://github.com/dansteingart/Ardustat/](https://github.com/dansteingart/Ardustat/)>



?



If so, this seems to communicate with the host via serial.



And Twisted includes facilities to communicate over serial _without_

blocking and without using background threads. See eg

https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/wamp/__serial2ws

<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/serial2ws](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/serial2ws)>




In general, it would help if you could post some code or provide

more detail about the code that interfaces with your hardware. That

way, we might be able to give you more specific hints ..



/Tobias





    now, if I put it in the reactor it would definitely block it. I was

    wondering if it would be easier to leave it outside the reactor

    or to

    put it inside and tweak it a little. Sounds like the latter is

    the best

    option.

    Thanks,

    Dan D





    On Sun, Jan 19, 2014 at 5:12 AM, Tobias Oberstein

    <tobias.o...@gmail.com <mailto:tobias.oberstein@gmail.com>

<mailto:tobias.oberstein@__gmail.com

    <mailto:tobias.oberstein@gmail.com>>> wrote:

Am 19.01.2014 02:22, schrieb Daniel Davies:

             Thanks again Tobias.



             I've got everything pretty much the way wanted it to.

    Is there a

             way to





         Great!





             communicate with things inside the reactor from outside

    of it?

             Or is it

             more common to do everything inside the reactor?





         Not sure what you mean.



         You program will at some point do



         reactor.run()



         And this function never returns (well, if it does, the only

    sensible

         thing is to exit, since you cannot restart the Twisted

    reactor).



         In this sense, everything in your program is run "under the

    reactor"

         (since you stuff is triggered from the event loop running

    in the

         reactor).



         And the reactor runs on the first thread (the main thread)

    of your

         Python process.



         Now, the exception to this if you use background threads.

    Either

         explicitly via deferToThread etc, or implicitly by using

         twisted.enterprise.adbapi.



         The general advice is: write code non-blocking "Twisted

    style" and

         run it on the main thread (under the reactor), unless one

    of the

         following:



         1. You are doing CPU intensive stuff (run that on

    background thread,

         otherwise it'll block your networking, and you won't make

    use of

         multicore CPUs)



         2. You _must_ call some 3rd party _blocking_ code (eg. database

         drivers etc) - again run on background thread.



         Hope this helps,



         /Tobias







             Dan D





             On Sun, Jan 5, 2014 at 6:30 PM, Daniel Davies

             <dmda...@princeton.edu <mailto:dmda...@princeton.edu>

    <mailto:dmda...@princeton.edu <mailto:dmda...@princeton.edu>__>

<mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>

             <mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>__>__>> wrote:

Ok thanks!

                  Might take a little longer but again ill probably

    be in

             touch again

                  soon.

                  Dan D





                  On Mon, Jan 6, 2014 at 12:28 PM, Tobias Oberstein

                  <tobias.o...@gmail.com

    <mailto:tobias.oberstein@gmail.com>

             <mailto:tobias.oberstein@__[gmail.com](http://gmail.com)

    <mailto:tobias.oberstein@gmail.com>>

<mailto:tobias.oberstein@

    <mailto:tobias.oberstein@>__[gma__il.com](http://gma__il.com) <[http://gmail.com](http://gmail.com)>


             <mailto:tobias.oberstein@__[gmail.com](http://gmail.com)

    <mailto:tobias.oberstein@gmail.com>>>> wrote:

Am 06.01.2014 00:22, schrieb Daniel Davies:

                          Righto, so i just put this into my

    protocol class.

             Doesn't

                          seem to work

                          as it should, it only seems to call

    RPCon() and

             then doesn't

                          do anything

                          from there.





                      Well;)



                      You can try

https://github.com/tavendo/______AutobahnPython/blob/master/______examples/twisted/websocket/______echo/client_coroutines.py

    <[https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py](https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py)>




    <[https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py](https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py)


    <[https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py](https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py)>>










    <[https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py](https://github.com/tavendo/____AutobahnPython/blob/master/____examples/twisted/websocket/____echo/client_coroutines.py)


    <[https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py](https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py)>




    <[https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py](https://github.com/tavendo/__AutobahnPython/blob/master/__examples/twisted/websocket/__echo/client_coroutines.py)


    <[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/echo/client_coroutines.py)>>>




                      from this example

https://github.com/tavendo/______AutobahnPython/tree/master/______examples/twisted/websocket/______echo

    <[https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo](https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo)>




    <[https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo](https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo)


    <[https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo](https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo)>>










    <[https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo](https://github.com/tavendo/____AutobahnPython/tree/master/____examples/twisted/websocket/____echo)


    <[https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo](https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo)>




    <[https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo](https://github.com/tavendo/__AutobahnPython/tree/master/__examples/twisted/websocket/__echo)


    <[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo)>>>




                      And then debug your code ..





                          Will be looking around twisted to try work

    out how

             to do it.



                          Thanks,



                          Dan D





                          def sleep(delay):



                          d = Deferred()



                          reactor.callLater(delay, d.callback, None)



                          return d







                          @inlineCallbacks



                          def simpleblink(self):



                          for i in range(5):



                          self.RPCon()



                          yield self.sleep(5)



                          self.RPCoff()



                          yield self.sleep(5)







                          On Mon, Jan 6, 2014 at 12:00 PM, Daniel Davies

                          <dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>

             <mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>__>

    <mailto:dmda...@princeton.edu <mailto:dmda...@princeton.edu>

             <mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>__>__>

                          <mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>

             <mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>__>



                          <mailto:dmda...@princeton.edu

    <mailto:dmda...@princeton.edu>

             <mailto:dmda...@princeton.edu

mailto:dmda...@princeton.edu>>__>> wrote:

                               Thanks!

                               I thought it might be something like

    that.

                               I'll give it a go. I'm guessing I

    could poke

             around the

                          twisted

                               website to get an intro on asynchronous

             programming and

                          twisted.

                               Will let you know how I go shortly.

                               Dan D





                               On Mon, Jan 6, 2014 at 11:47 AM,

    Tobias Oberstein

                               <tobias.o...@gmail.com

    <mailto:tobias.oberstein@gmail.com>

             <mailto:tobias.oberstein@__[gmail.com](http://gmail.com)

    <mailto:tobias.oberstein@gmail.com>>

                          <mailto:tobias.oberstein@

    <mailto:tobias.oberstein@>__[gma__il.com](http://gma__il.com) <[http://gmail.com](http://gmail.com)>


             <mailto:tobias.oberstein@__[gmail.com](http://gmail.com)

    <mailto:tobias.oberstein@gmail.com>>>

<mailto:tobias.oberstein@

    <mailto:tobias.oberstein@>

             <mailto:tobias.oberstein@

    <mailto:tobias.oberstein@>>__[gm__a__il.com](http://gm__a__il.com) <[http://gma__il.com](http://gma__il.com)>


    <[http://gmail.com](http://gmail.com)>






                          <mailto:tobias.oberstein@

    <mailto:tobias.oberstein@>__[gma__il.com](http://gma__il.com) <[http://gmail.com](http://gmail.com)>


             <mailto:tobias.oberstein@__[gmail.com](http://gmail.com)

    <mailto:tobias.oberstein@gmail.com>>>>> wrote:



                                       The issue that I need help

    with right

             now is

                          the following

                                       method.



                                       def simpleblink(self):



                                            print "trying to blink"



                                            i = 0



                                            self.RPCoff



                                            while (i < 5):



                                               reactor.callLater(5,

    self.RPCon)



                                               reactor.callLater(5,

    self.RPCoff)



                                               i = i+1





                                   This won't work as you intend.

    It'll schedule

                          turning on and off

                                   the LED 5 times immediately one after

             another -

                          after a delay of

                                   5secs.

                                   It'll likely be too fast to see any

             blinking at all.



                                   I can't give you an intro to

    Twisted and

             asynchronous

                                   programming, but what you are

    doing is ..

             wrong;)



                                   There is a way of doing asynchronous

             programming

                          which looks

                                   (and mostly works) like

    sequential code.



                                   Try this:



                                   from twisted.internet.defer

    import Deferred,

                          inlineCallbacks



                                   def sleep(delay):

                                       d = Deferred()

                                       reactor.callLater(delay,

    d.callback, None)

                                       return d



                                   class YourProtocol:

                                       @inlineCallbacks

                                       def simpleblink(self):

                                          for i in range(5):

                                             self.RPCon()

                                             yield sleep(5)

                                             self.RPCoff()

                                             yield sleep(5)





                                   This assume your RPCon/off

    methods are

             working as

                          advertised ..



                                   Hope that gets you further,



                                   /Tobias





                                   --

                                   You received this message because

    you are

                          subscribed to the

                                   Google Groups "Autobahn" group.

                                   To unsubscribe from this group

    and stop

             receiving

                          emails from

                                   it, send an email to

autobahnws+unsubscribe@__googl______egroups.com

    <[http://googl____egroups.com](http://googl____egroups.com)>

             <[http://googl__egroups.com](http://googl__egroups.com)>

                          <[http://googlegroups.com](http://googlegroups.com)>





    <mailto:autobahnws%______2Bunsu...@googlegroups.com

    <mailto:autobahnws%25____2Bunsu...@googlegroups.com>

             <mailto:autobahnws%25____2Bunsu...@googlegroups.com

    <mailto:autobahnws%2525__2Bunsu...@googlegroups.com>__>



             <mailto:autobahnws%____252Bunsubscribe@googlegroups.

    <mailto:autobahnws%25__252Bunsubscribe@googlegroups.>____com



    <mailto:autobahnws%__25252Bunsubscribe@__[googlegroups.com](http://googlegroups.com)

    <mailto:autobahnws%2525252Bunsubscribe@googlegroups.com>>>__>.

                                   For more options, visit

    [https://groups.google.com/________groups/opt_out](https://groups.google.com/________groups/opt_out)

    <[https://groups.google.com/______groups/opt_out](https://groups.google.com/______groups/opt_out)>


             <[https://groups.google.com/______groups/opt_out](https://groups.google.com/______groups/opt_out)

    <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)>>





      <[https://groups.google.com/______groups/opt_out](https://groups.google.com/______groups/opt_out)

    <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)>

             <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>>>





               <[https://groups.google.com/______groups/opt_out](https://groups.google.com/______groups/opt_out)

    <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)>

             <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>>



      <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>

             <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>>>.









                          --

                          You received this message because you are

             subscribed to the

                          Google

                          Groups "Autobahn" group.

                          To unsubscribe from this group and stop

    receiving

             emails

                          from it, send

                          an email to

             autobahnws+unsubscribe@__[googl____egroups.com](http://googl____egroups.com)

    <[http://googl__egroups.com](http://googl__egroups.com)>

             <[http://googlegroups.com](http://googlegroups.com)>



      <mailto:autobahnws%____2Bunsu...@googlegroups.com

    <mailto:autobahnws%25__2Bunsu...@googlegroups.com>

             <mailto:autobahnws%__252Bunsubscribe@googlegroups.__com

    <mailto:autobahnws%25252Bunsubscribe@googlegroups.com>>__>.

                          For more options, visit

    [https://groups.google.com/______groups/opt_out](https://groups.google.com/______groups/opt_out)

    <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)>

             <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>>



      <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>

             <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>>.





                      --

                      You received this message because you are

    subscribed to the

                      Google Groups "Autobahn" group.

                      To unsubscribe from this group and stop receiving

             emails from

                      it, send an email to

             autobahnws+unsubscribe@__[googl____egroups.com](http://googl____egroups.com)

    <[http://googl__egroups.com](http://googl__egroups.com)>

             <[http://googlegroups.com](http://googlegroups.com)>



      <mailto:autobahnws%____2Bunsu...@googlegroups.com

    <mailto:autobahnws%25__2Bunsu...@googlegroups.com>

             <mailto:autobahnws%__252Bunsubscribe@googlegroups.__com

    <mailto:autobahnws%25252Bunsubscribe@googlegroups.com>>__>.

                      For more options, visit

    [https://groups.google.com/______groups/opt_out](https://groups.google.com/______groups/opt_out)

    <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)>

             <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>>

                      <[https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>

             <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>>.







             --

             You received this message because you are subscribed to

    the Google

             Groups "Autobahn" group.

             To unsubscribe from this group and stop receiving

    emails from

             it, send

             an email to autobahnws+unsubscribe@__[googl__egroups.com](http://googl__egroups.com)

    <[http://googlegroups.com](http://googlegroups.com)>

             <mailto:autobahnws%__2Bunsu...@googlegroups.com

    <mailto:autobahnws%252Bunsubscribe@googlegroups.com>__>.

             For more options, visit

    [https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>

             <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>.





         --

         You received this message because you are subscribed to the

    Google

         Groups "Autobahn" group.

         To unsubscribe from this group and stop receiving emails

    from it,

         send an email to

    autobahnws+unsubscribe@__[googl__egroups.com](http://googl__egroups.com)

    <[http://googlegroups.com](http://googlegroups.com)>

         <mailto:autobahnws%__2Bunsu...@googlegroups.com

    <mailto:autobahnws%252Bunsubscribe@googlegroups.com>__>.

         For more options, visit

    [https://groups.google.com/____groups/opt_out](https://groups.google.com/____groups/opt_out)

    <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)>

         <[https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>>.





    --

    You received this message because you are subscribed to the Google

    Groups "Autobahn" group.

    To unsubscribe from this group and stop receiving emails from

    it, send

    an email to autobahnws+unsubscribe@__[googlegroups.com](http://googlegroups.com)

    <mailto:autobahnws%2Bunsu...@googlegroups.com>.

    For more options, visit

    [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

    <[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.





--

You received this message because you are subscribed to the Google

Groups "Autobahn" group.

To unsubscribe from this group and stop receiving emails from it,

send an email to autobahnws+unsubscribe@__[googlegroups.com](http://googlegroups.com)

<mailto:autobahnws%2Bunsu...@googlegroups.com>.

For more options, visit [https://groups.google.com/__groups/opt_out](https://groups.google.com/__groups/opt_out)

<[https://groups.google.com/groups/opt_out](https://groups.google.com/groups/opt_out)>.

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+unsubscribe@googlegroups.com.

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

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

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

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

0 Likes