Prototype Minster Music Software

This Forum is for discussion about the development of the software to control the playing of the music in the Minster Nave and the bells in the Tower.

There will be two programs; both based on the original software but now running on two Pis.
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Prototype Minster Music Software

Post by hamishmb »

Okay, here are my findings.

1: Please include a full tarball next time - I had to copy the Tools package from rivercontrolsystem but I don't know if you've made any changes. Hopefully not. I also had to re-create some the the directory structure the code expects to be in place.

2: I get an "Invalid System ID" error from sockettools.py when starting your minstermusic.py program, until I modify it to include the correct System ID:

Code: Select all

socket = socket_tools.Sockets("Socket", "BELLS", site_settings["SocketName"])
You may be getting confused here because the socket name is an optional argument. Then again, I don't know if you made any modifications to sockettools.py.

Likewise for minsterbells.py:

Code: Select all

socket = socket_tools.Sockets("Plug", "BELLS", config.SITE_SETTINGS["BELLS"]["SocketName"])
3:

The reason they can't connect is that in config.py ServerAddress for BELLS is set to 192.168.0.25 (the NAS box IP). After changing this to 192.168.10.1 it should work. I tested locally with 127.0.0.1 and it worked okay.

4:

Maybe there should be a note in minstermusic.py that site_settings refers to the settings for BELLS, not MUSIC. Seeing as this is a global variable, I can see it causing problems in the future due to confusion. Perhaps renaming it or deleting it afterwards is a good idea.

I now have them talking to each other, so hopefully my notes above get it working for you too. If this is in a git repository somewhere I'll be happy to submit a pull request with these changes. I just tested locally on my desktop so I had to comment some things out - hopefully I didn't change anything extra without realising.
Hamish
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Prototype Minster Music Software

Post by TerryJC »

Thanks for the guidance. I'll update my code and make sure it works OK.

Here are my responses to some of your comments:
hamishmb wrote: 08/01/2021, 13:351: Please include a full tarball next time - I had to copy the Tools package from rivercontrolsystem but I don't know if you've made any changes. Hopefully not. I also had to re-create some the the directory structure the code expects to be in place.
Sorry. I did a Pull from GitHub before I started so that I had the latest version as you recommended above. I never thought of the sub-directories.
hamishmb wrote: 08/01/2021, 13:35You may be getting confused here because the socket name is an optional argument. Then again, I don't know if you made any modifications to sockettools.py.
Yes. I was certainly confused.
hamishmb wrote: 08/01/2021, 13:35The reason they can't connect is that in config.py ServerAddress for BELLS is set to 192.168.0.25 (the NAS box IP). After changing this to 192.168.10.1 it should work. I tested locally with 127.0.0.1 and it worked okay.
Whoops. I hadn't realised that. Thanks.
hamishmb wrote: 08/01/2021, 13:35Maybe there should be a note in minstermusic.py that site_settings refers to the settings for BELLS, not MUSIC. Seeing as this is a global variable, I can see it causing problems in the future due to confusion. Perhaps renaming it or deleting it afterwards is a good idea.
I'll update this.
Terry
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Prototype Minster Music Software

Post by TerryJC »

hamishmb wrote: 08/01/2021, 13:352: I get an "Invalid System ID" error from sockettools.py when starting your minstermusic.py program, until I modify it to include the correct System ID:

Code: Select all

socket = socket_tools.Sockets("Socket", "BELLS", site_settings["SocketName"])
Likewise for minsterbells.py:

Code: Select all

socket = socket_tools.Sockets("Plug", "BELLS", config.SITE_SETTINGS["BELLS"]["SocketName"])
I remember now why I removed "BELLS"; I get an error about too many arguments if I don't. When I looked at the Sockets Method in sockettools I saw that it was only expecting two arguments, so that is what I gave it. I meant to ask you about it at the time.

With the correction to the ServerAddress in Config.py, the two Pis connect OK as long as I don't apply the above fix.

Can you shed any light on why your code works for you (and presumably in the River System), but not here on my Minster system?
Terry
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Prototype Minster Music Software

Post by TerryJC »

Hamish,

Not much progress over the weekend (multiple appliance failures; microwave, toaster and car charger :cry: ). Back on the job now and the sockets code appears to be working.

However, on connection, both Pis print "Connected to peer (Music Pi Socket)", which isn't what I would expect; this sounds wrong for both Pis because:
  • The Music Pi is the server, so I would expect it to say "Connected to peer (Bells Pi Socket)".
  • The Bells Pi is the client, so I would expect it to say "Connected to server (Music Pi Socket)".
I'm thinking that this may be related to my previous query.
Terry
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Prototype Minster Music Software

Post by hamishmb »

For the 2nd query:

This depends on the third argument given to socket_tools.Sockets - if you want a different socket name, supply a different third argument.

For the first query:

Could you provide a full downloadable archive (or preferably a link to a git repository) with your code in please so I can check everything is as it should be?
Hamish
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Prototype Minster Music Software

Post by TerryJC »

hamishmb wrote: 12/01/2021, 11:54 For the 2nd query:

This depends on the third argument given to socket_tools.Sockets - if you want a different socket name, supply a different third argument.
That was the point of the first query it won't let me add a third argument :)
hamishmb wrote: 12/01/2021, 11:54For the first query:

Could you provide a full downloadable archive (or preferably a link to a git repository) with your code in please so I can check everything is as it should be?
See: https://gitlab.com/wmtprojectsteam/mins ... ngineering
Terry
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Prototype Minster Music Software

Post by hamishmb »

Thanks for the link.

The version of sockettools.py you're using (and hence probably also that of loggingtools.py) are not the current ones in the master branch from the River Control System master branch and are thus outdated and do not have the 3rd argument - that is the source of the problem.

The existing sockettools.py you have may work fine, but is likely to contain significant bugs considering its age. Do you know what commit this is from?

You'll also need to change these lines:

Code: Select all

logger.setLevel(logging.getLogger('River System Control Software').getEffectiveLevel())

for handler in logging.getLogger('River System Control Software').handlers:
    logger.addHandler(handler)
To match the name of the logger this software uses, or the level and handler(s) won't get set up correctly. It seems you've used different logger names for the minster bells and minster music software, so those probably need to be made the same, unless sockettools.py is modified to get the same from eg config.py when it starts.

Hope this helps,
Hamish
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Prototype Minster Music Software

Post by hamishmb »

NB: Also the shebangs shouldn't have whitespace in them, they should be eg:

Code: Select all

#!/usr/bin/env python3
Instead of:

Code: Select all

#! /usr/bin/env python3
Hamish
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Prototype Minster Music Software

Post by TerryJC »

hamishmb wrote: 15/01/2021, 17:40 Thanks for the link.

The version of sockettools.py you're using (and hence probably also that of loggingtools.py) are not the current ones in the master branch from the River Control System master branch and are thus outdated and do not have the 3rd argument - that is the source of the problem.

The existing sockettools.py you have may work fine, but is likely to contain significant bugs considering its age. Do you know what commit this is from?
I did a pull back on December when you told me to viewtopic.php?p=4612#p4612. At the time it worked fine, but this is what I got just now:

Code: Select all

terry@OptiPlex:~/Development/Wimborne_Model_Town/River_System/Code/git_repository/rivercontrolsystem$ git pull origin master
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:

  git config pull.rebase false  # merge (the default strategy)
  git config pull.rebase true   # rebase
  git config pull.ff only       # fast-forward only

You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.

From gitlab.com:wmtprojectsteam/rivercontrolsystem
 * branch            master     -> FETCH_HEAD
Already up-to-date.
So which should I do merge, rebase or fast-forward?

Note that git thinks the code is up to date with master.
Terry
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Prototype Minster Music Software

Post by TerryJC »

hamishmb wrote: 15/01/2021, 17:40You'll also need to change these lines:

Code: Select all

logger.setLevel(logging.getLogger('River System Control Software').getEffectiveLevel())

for handler in logging.getLogger('River System Control Software').handlers:
    logger.addHandler(handler)
To match the name of the logger this software uses, or the level and handler(s) won't get set up correctly. It seems you've used different logger names for the minster bells and minster music software, so those probably need to be made the same, unless sockettools.py is modified to get the same from eg config.py when it starts.
Hamish,

I can't see either of these lines in my code. Which lines should be changed?

Also, I created the logging section of the software by cutting and pasting, so I can't see where they are different.
Terry
Post Reply