EricssonResearch / calvin-base

Calvin is an application environment that lets things talk to things, among other things.
Apache License 2.0
282 stars 91 forks source link

Problematic simultaneous runtimes #102

Closed Tatiana-runco closed 5 years ago

Tatiana-runco commented 6 years ago

I run 2 runtimes "(test-calvin) tatu @ tatu-notebook: ~ / calvin-base-develop / calvin / examples / ui_in_gui $ csruntime --host 127.0.0.1 --port 5002 --controlport 5003 --name another_runtime" y "(test-calvin) tatu @ tatu-notebook: / etc $ csruntime --host 127.0.0.1 --port 5000 --controlport 5001 --name El-primerot "running in different folders, you can see the route in the screenshots and the error that happens. Someone could help me with this? 1 2

olaan commented 6 years ago

This can sometimes happen when one of the runtimes disappears (stops, restarts, or connection loss). I can only suggest restarting all of the runtimes. You could also try running with a proxy storage - see https://github.com/EricssonResearch/calvin-base/wiki/Configuration for details.

Cheers.

Tatiana-runco commented 6 years ago

Why would a runtime disappear? I did restart the runtimes, even provided with new and different. But the problem arises when I launch two runtimes at the same time. Could it be something in the configuration that is not right?

olaan commented 6 years ago

A runtime disappears when you restart it. When using the DHT, all runtimes have to be completely stopped before you can restart them - otherwise you will get these errors. Did you try with proxy storage (see my last comment)? That usually fixes issues related to the DHT.

Tatiana-runco commented 6 years ago

I have read https://github.com/EricssonResearch/calvin-base/wiki/Configuration but it is not clear to me that it may be failing. Run 2 runtimes on different computers to server 127.0.0.1 port 5000 and 5002 with port control 5001 and 5003 respectively and the message was as follows:

r: There are no known neighbors to set key actor_type-4a179364d294ae18380fab2e4322689f38936b6b667b4ffbdc34bb1454a10b0f 2018-09-15 17:55:36,913 WARNING 4543-calvin.calvin.runtime.south.storage.twistedimpl.dht.append_server: There are no known neighbors to set key actor_type-c1c4e613a03eab4307378303944f1d98d1e4f2c1ea3340424f25ac6bc457bdc5

I also did: as it says in https://github.com/EricssonResearch/calvin-base/wiki/Configuration "Proxy Example Usage" CALVIN_GLOBAL_STORAGE_TYPE = \ "local \" csruntime -n $ IP_ADDR -p 5010 -c 5011 & replacing the ip of my pc and the error says: that the ip or the port are in use. I attach snapshots of the errors. ip con-laip1 con-laip2

olaan commented 6 years ago

So, first of all, when you are using Calvin on two different computers, then you cannot use the localhost address (127.0.0.1) - you have to use an address that is reachable from the other computer. An easy way to ensure that you use the correct addresses is to try to ping it from the other machine. If it works, then it should be possible for Calvin to use this address as well.

Using the screenshot above, you would start the Calvin runtime on that computer with

csruntime --host 192.168.1.68 --name calvin-1

Note that port and control port are set by default, and if you are running on different computers, you can use the same port numbers on both, there is no need to set it to something different.

The reason you are seeing the "Did not receive reply..." messages is probably because you started the runtime with a localhost address. This address is not visible to other computers (they can only see traffic on their own) so when you use that address when starting a runtime, the runtime will tell all other runtimes that this is the address to use for communication. Since this is not possible, there will never be a reply, and thus you get the message you get.

So, try again, but do not use 127.0.0.1 as an address.

Tatiana-runco commented 6 years ago

Try with the ip of my computer and localhost in the sentences to raise a new execution time and it worked. What does not work is the example of https://github.com/EricssonResearch/calvin-base/wiki/Calvin-GUI in the "Start a new runtime" section where the ip is 127.0.0.1 and ports 5000 and 5001 for one execution time and for the other 5002 and 5003.

Tatiana-runco commented 6 years ago

In https://github.com/EricssonResearch/calvin-base/wiki/MiniTutorial, section "A second example" with an example similar to the previous ones where we raise execution times in the same pc (same ip) I get the same error attached screenshots to illustrate. 1 2

olaan commented 6 years ago

Please attach complete logs as text and not as images. The screenshots do not give any useful information.

Tatiana-runco commented 5 years ago

Hi @olaan

I could not solve the previous question, but I do not have time to linger with that. Continue working with Calvin, make the connection of a temperature sensor in order to create an application that works with the temperature data that it throws. Below I show the connection circuit. Using it simply with Python this works great, but I do not know if it is well connected to Calvin or if I do not understand how to use it with the actors that Calvin has. Could you help me with this please? image

Tatiana-runco commented 5 years ago

Simply using Python:

1

With Calvin:

2

olaan commented 5 years ago

The DHT-11 is one of the sensors described in the sensor-kit example. The implementation does not support reading of temperature from that sensor because of poor resolution. It can be used as a humidity sensor.

What you need to do is to add the sensor to the configuration file of the runtime. The configuration should be named calvin.conf and located in the directory where you start the runtime. The sensor-kit example uses the configuration file calvin-base/calvin/examples/sensor-kit/calvin.conf. Make sure you have read the instruction file for the example. It can be found in this repository. As I said, the DHT-11 can only be used for sensing humidity. The default is to use GPIO pin 19 (which is board pin 35) as data pin, but you can change that to reflect your setup. It looks like you're using board pin 16 (which is GPIO pin 23), so just edit the file to read:

"io.humidity": {
    "module": "io.dht11temphumidity.raspberry_pi.DHT11",
    "attributes": {"pin": 23}
}

The module requires the pigpio package, so install them first:

sudo apt-get update && sudo apt-get install pigpio python-pigpio

and start the pigpio-daemon:

sudo pigpiod

Note that by default, the daemon will not restart when you restart the raspberry pi. You can read more about pigpio here: http://abyz.me.uk/rpi/pigpio/download.html.

Start the runtime in the directory where you have your (edited) calvin.conf file. Note that you need to start the runtime without --gui-mock-devices in order to use the hardware. If everything is set up correctly, the following application should produce an output on the console (every second):

tick: std.Trigger(tick=1.0, data=true)
sensor: sensor.TriggeredRelativeHumidity()
out : io.Print()

tick.data > sensor.measure
sensor.percent > out.token

If there is a problem, try starting calvin with an explicit config path:

CALVIN_CONFIG_PATH=$(pwd) csruntime --host localhost --gui

Provided you are in the same directory as the calvin.conf file, it should help calvin find the correct configuration file.

That should get you started.

Cheers.

Tatiana-runco commented 5 years ago

hello @olaan But the KY-001 temperature sensor if I can use it to sense true temperature data? And the humidity sensor should be the KY-015 TEMPERATURE AND HUMIDITY SENSOR MODULE?

Another question is whether all the sensors that appear in the readme.html of the sensor-kit are suitable for use with my raspberry 3?

can more than one sensor (same type for example temperature) be connected to the same raspberry pi, at the same time?

Person for so many questions is that I need to make sure before buying the sensors.

Thanks!!!

olaan commented 5 years ago

Hello.

We'll see if we can get the KY-015 to work. Let me get back to you early next week.

Cheers,

// Ola

Tatiana-runco commented 5 years ago

Great thanks!!

olaan commented 5 years ago

The develop branch now allows for the DHT11 to be used both as a temperature and humidity sensor. Could you verify that this solves your issue? There has not been a new release, so you need checkout the develop branch manually.

Cheers.

Tatiana-runco commented 5 years ago

Helllo @olaan Thank you very much for the help you are giving me. It is very valuable to me. I show in an image that the sensor continues to give the same data, maybe I did not understand the part of manually reviewing the developer branch. But always download the developer repositories I also show you an image of that from my Raspberry

image image

olaan commented 5 years ago

When using real devices you cannot use the default simulated devices in the gui. Instead, you need to edit your configuration (in calvin.conf) to include which real devices and which simulated devices you want to use. If you want the print-actor to send data to the gui but use the DHT11 for humidity and temperature, you should use a configuration which looks like this:

{
    "global": {
        "storage_type": "local"
    },
    "calvinsys": {
        "capabilities": {
           "io.stdout": {
                "module": "ui.StandardOut",
                "attributes": {"ui_def": {"control":{"type":"console"}}}
            },
            "io.humidity": {
                "comment": "DHT11 sensor, relative humidity",
                "module": "io.dht11temphumidity.raspberry_pi.DHT11",
                "attributes": {"pin": 19, "mode": "humidity"}
            },
            "io.temperature": {
                "comment": "DHT11 sensor, temperature",
                "module": "io.dht11temphumidity.raspberry_pi.DHT11",
                "attributes": {"pin": 19, "mode": "temperature"}
            }
        }
    }
}

You should save this to a file named calvin.conf and then start the calvin runtime in the directory this file is saved in. You should not use the flag --gui-mocked-devices when starting the runtime, otherwise the runtime will not use the real devices.

Also, make sure you have the very latest version of the commit branch.

Cheers.

Tatiana-runco commented 5 years ago

Realize the steps as your explanation, but the results are bad. 1 2 Result.txt

The connection of the temperature sensor is the one described above but not to pin 16, if to 19 as it is in the file calvin.conf image

olaan commented 5 years ago

In order to change the pin used, update the calvin.conf file or move the blue wire to pin 19.

I am unsure of what the problem shown in the screenshot could be. Have you installed pigpio?

sudo apt-get update 
sudo apt-get install pigpio python-pigpio

Let me know if this helps.

Tatiana-runco commented 5 years ago

Hi @olaan I have reviewed every point where he told me to modify and with this I have been very careful. It is extremely important for me that it works. But even so it did not work. It is assumed that the temperature.calvin execution should show the temperature sensed by the DHT11?

olaan commented 5 years ago

Let's see what the problem could be then.

The calvin.conf I gave above assumes you are using the GUI and will send the output of the io.Printactor to the window in the GUI. In order to send the output to the terminal remove the following from the configuration file:

           "io.stdout": {
                "module": "ui.StandardOut",
                "attributes": {"ui_def": {"control":{"type":"console"}}}
            },

Also, could you try starting the runtime with the following line (in the directory where you have your calvin.conf and the temperature.calvin program:

csruntime --host localhost -w20 temperature.calvin --logfile testfile.log

Once it finishes, post the file testfile.log here and I will see if I can spot what's wrong.

Cheers.

Tatiana-runco commented 5 years ago

The result is testfile.log

Thank you!!

olaan commented 5 years ago

From what I can see, everything is working as expected. Excellent!

I will close this issue now. Just open a new one if you encounter more problems.

Cheers.

Tatiana-runco commented 5 years ago

So the output of the DHT11 sensor at 0.0 is normal? I'm surprised that the ambient temperature is that. It should be about 25 degrees centigrade aprox. image

olaan commented 5 years ago

I did not read through the log carefully enough. You are using an old version of Calvin which cannot read temperature from the DHT11. You need to update to the most recent version of the develop branch.

Possibly, the documentation could be even more clear on what pin means. (I see that I made a mistake in one of my answers above - will fix it.) In the configuration, pin means GPIO-pin and not board pin. The pin marked 16 in your image above is GPIO 23.

EDIT: The pinout is described on the wiki at https://github.com/EricssonResearch/calvin-base/wiki/SensorKit#pinout

Cheers.

Tatiana-runco commented 5 years ago

When I updated the version a few days ago, I downloaded the ZIP of https://github.com/EricssonResearch/calvin-base/tree/develop and did the installation again. That would be a valid way to update to the latest version? Soon I will try with pin 23 in my raspberry pi

olaan commented 5 years ago

That would be the way to do it but the log you sent shows an older version. The timeout message changed when I updated the DHT11 implementation. It should read

2019-01-04 13:02:37,150 INFO     18076-calvin.calvinextras.calvinsys.io.dht11temphumidity.raspberry_pi.DHT11: DHT11 read timeout, using old values: {'temperature': 21, 'humidity': 18}

Could you repeat the installation and try again? If that doesn't work, post the steps you took and I'll see if I can spot the issue.

Cheers.

Tatiana-runco commented 5 years ago

In Raspberry pi:

  1. Download the zip of https://github.com/EricssonResearch/calvin-base/tree/develop
  2. Installation: pip install er-calvin

sudo apt-get update

sudo apt-get install -y python python-dev build -essential git libssl-dev libffi-dev

sudo apt-get remove -and python-pip

curl https://bootstrap.pypa.io/get-pip.py -o - | python (this step does not let me do it)

cd calvin-base

python setup.py install

cd / home / user / calvin-base

pip install -e.

pip install -r test-requirements.txt

  1. cd /home/pi/calvin-base-develop/calvin/examples/temperature/ sudo pigpiod csruntime --host localhost -w0 temperature.calvin

Then the result remains the same

calvin.conf: { "global": { "storage_type": "local" }, "calvinsys": { "capabilities": {
"io.humidity": { "comment": "DHT11 sensor, relative humidity", "module": "io.dht11temphumidity.raspberry_pi.DHT11", "attributes": {"pin": 19, "mode": "humidity"} }, "io.temperature": { "comment": "DHT11 sensor, temperature", "module": "io.dht11temphumidity.raspberry_pi.DHT11", "attributes": {"pin": 19, "mode": "temperature"} } } } }

Raspberry : 20190104_195555

change the cable on pin 23 as seen in the picture

olaan commented 5 years ago

You are mixing different ways of installing Calvin. Avoid this.

Install Calvin:

  1. sudo apt-get install -y unzip curl libssl-dev libffi-dev
  2. curl -L -o calvin-base-develop.zip https://github.com/EricssonResearch/calvin-base/archive/develop.zip
  3. unzip calvin-base-develop.zip
  4. cd calvin-base-develop
  5. pip install -r requirements.txt -e .

You misunderstood my description of the pins.

  1. Use your previous connection image

  2. Change calvin.conf to:

{
    "global": {
        "storage_type": "local"
    },
    "calvinsys": {
        "capabilities": {
            "io.humidity": {
                "comment": "DHT11 sensor, relative humidity",
                "module": "io.dht11temphumidity.raspberry_pi.DHT11",
                "attributes": {"pin": 23, "mode": "humidity"}
            },
            "io.temperature": {
                "comment": "DHT11 sensor, temperature",
                "module": "io.dht11temphumidity.raspberry_pi.DHT11",
                "attributes": {"pin": 23, "mode": "temperature"}
            }
        }
    }
}
  1. Run your application.
Tatiana-runco commented 5 years ago

I executed my application with the steps of the previous message and everything worked perfectly. It really has been useful to me. Thank you very much for your help.

perfect

olaan commented 5 years ago

You're welcome.

Tatiana-runco commented 5 years ago

Hello @olaan Sorry to return to consult, I was left with the error of the simultaneous execution times. For example, in my raspberry I execute "csruntime --host 192.168.1.35 --name calvin-1" such ip is the one assigned to my raspberry by my wi-fi network. Then in my Notebook I run "csruntime --host 192.168.1.41 --name calvin-2" and that's when the error arises. Attached txt of the same. I was also testing the proxy storage but in the https://github.com/EricssonResearch/calvin-base/wiki/Configuration configuration there is not an example to run the proxy storage. Can you help me with this please?

error.txt

olaan commented 5 years ago

(Avoid posting comments in closed issues.)

Use the proxy-registry by starting the runtimes like this:

On your notebook:

CALVIN_STORAGE_TYPE=\"local\" csruntime --host 192.168.1.41 --name calvin-2

On the raspberry:

CALVIN_STORAGE_TYPE=\"proxy\" CALVIN_STORAGE_PROXY=\"calvinip://192.168.1.41:5000\" csruntime --host 192.168.1.35 --name calvin-1

Cheers.

Tatiana-runco commented 5 years ago

Yes it works, when I check it in the GUI I see both execution times and I can migrate a notebook actor to raspberry. However, the message "twisted: 'Did not receive reply for msg id" does not stop printing in the console of both execution times. It may be necessary to configure something of: Configuring transports plugins By default Calvin registers calvinip as an possible transport interface, additional interfaces to register can be specified with "transports" in calvin.conf:

{ "global": { "transports": ["calvinbt"] } } Configuring a Control API proxy A remote Calvin runtime can be used as an proxy for the Control API by specifying the uri in calvin.conf:

{ "global": { "control_proxy": "calvinbt://E8:B1:FC:F1:87:AD:1" } } Configuring a storage proxy A remote Calvin runtime can be used as a registry proxy by specifying the uri in calvin.conf:

{ "global": { "storage_proxy": "calvinbt://E8:B1:FC:F1:87:AD:1" } }

?

olaan commented 5 years ago

Again, please do not post questions in closed issues. Open a new one.

If the message "Did not receive reply for msg id" then you either have other runtimes running or you did not follow the instructions I gave. The command lines have to be entered exactly as shown.

The text you quote above is from the bluetooth setup and will be different for yours since you are not using bluetooth devices. You can add the proxy configuration to the calvin.conf but there will be no difference in the result.