Saving RaspberryPi sound configuration

One of the things that’s been bothering me with the Raspberry Pi, even though I’m managing it through Puppet, is the sound configuration.

Sometimes the sound is x% lower for no obvious reason, othertimes it goes through HDMI when I wanted it through the 3.5mm jack. Then I have to go figure out how to set it back all over again.

Turns out, the settings are loaded from a file, located at

/var/lib/alsa/asound.state

This means, that by changing some settings and saving again, it’s possible to see which parameters were modified, and then use this to create a template for use in Puppet.

To save the state:

alsactl store

For example, to change the output between auto/analog/hdmi, one would use the following command:

sudo amixer cset numid=3 1

which isn’t very explicit.

In the file, this will change the number corresponding to “value”:

control.3 {
	iface MIXER
	name 'PCM Playback Route'
	value 1
	comment {
		access 'read write'
		type INTEGER
		count 1
		range '0 - 2'
	}
}

On a Raspberry Pi, 0=auto; 1=analog; 2=HDMI.

To modify the output volume, you can set the “Value” in the first control to it’s highest value in the range:

control.1 {
	iface MIXER
	name 'PCM Playback Volume'
	value 400
	comment {
		access 'read write'
		type INTEGER
		count 1
		range '-10239 - 400'
		dbmin -9999999
		dbmax 400
		dbvalue.0 400
	}
}
Posted in Linux, Raspberry Pi, Software | Tagged , , , , , | Leave a comment

Race report: Aquathlon de St Priest

Yay! This weekend I participated in my first race since… ever!

The race was an Aquathlon, in Saint Priest (not too far away from Lyon).

This is one of my preferred race types, since it includes two of my least-hated sports: Swimming and Running.

I participated with a friend of mine, with who I’ve done some swim training and a bit of running. Unfortunately we couldn’t be in the same starting wave due to our different swimming speeds.

The race was 1Km swimming in a 25m pool, followed by 4.5km of running (announced).

The swim went quite well; trying to count laps quickly became impossible, so I just tried to stick to the people in front of me.

We were only 3 in our lane, all others were 4.

I was with one older guy and a young lady. We all started at the same speed, but I felt the girl was a bit slow, so I overpassed her; then after 1 length I figured I could get in front of the guy as well… so I did. I managed to do 3-4 lengths in front, but felt I’d quickly get tired, so I let the guy back in front, girl still behind. Later on she overtook me, but I stayed right behind her the rest of the time (yay for drafting!), while the guy lapped us once.

Getting out of the pool, I was just behind the girl, and there were still a few people in the pool finishing their laps. However, I was last out of transition (never done, not prepared) and I later learned that the girl was gone 45sec before I was.

On the running part, this was my worst; I haven’t really trained: only been out 3-4 times this year. The sun was high and it was quite hot, we had 3 soccer fields to run around.

After finishing the tour of the first soccer field, my legs still weren’t quite warmed up and I was running a bit fast, I felt like I was never going to make it… But I continued on, 2nd field wasn’t that hard, and the way around the end of the third was best, with a bit of wind and partially in the shade. On the second lap, once I was starting the 1st soccer field, the girl from my lane was already finishing it. Getting to the 2nd field I felt like it was all OK, this isn’t going to be too bad. But the part between 2nd and 3rd field is in a slope towards the right, twisting my feet a bit. Getting to the 2nd field on my 3rd run, I was like “Oh come on, not this shit again”; but soldiering on… I managed it.

In the end, I finished good last of my wave, 49th out of 54 in total… But hey, I finished!

Times:

19:31 for swimming+transition

30:29 for the running

So 50:oo in total, with the fastest being 34:57(12:37+22:20) and slowest bein 1:09:38 (no intermediate times)

They didn’t get the chronometers going for the first wave, of which my friend was in… So we don’t know all the times. He did however finish 38th, with a total of 46:07.

Overall, I was very happy with the day! Swimming is my “strong” part, but even with that I can see I’ve got a lot of progress to do if I ever want to be competitive. Running I know I’m not quite good at (yet!). I might try some short triathlons later on, but I’ll have to start training for the running, as well as picking up biking.

Also, my GPS watch announced the total running distance at 5.5kms, without having started right out of the pool. This also coincides with my friend’s impression of the circuit being longer.

Posted in Race report, Running, Sports, Swimming | Leave a comment

What class do we have next?

Timetables are one of the things my University just doesn’t get right.

You have to go on the website every now and then to either download your timetable as PDF, or export in iCal format if it’s available. But those aren’t going to be up to date if the timetable changes, and you’ll have to start over.

Up to now, there was always someone to come up with a system to provide an iCal link you could add to you calendar, which would always be up to date. This year however, the other year’s solutions are either down, or not updated for this school year… So I decided to give it a shot!

Since I know it’s possible to generate an ics from the website, I was hoping it would be possible to just call an URL and be done with it. Well, it’s not so simple; this solution doesn’t provide anything useful.

So I searched the web, and found some source code for some previous projects that access the same timetable software as me (ADE Campus).

One solution that came up, was to mimic a user interaction to generate the calendar. This ended up being kinda clunky, and didn’t really work well. Also I had no idea what I was doing.

The best solution however, came from some project who was kind enough to share their code on Google code, and it turns out ADE has a web API which is however undocumented.

This way, after getting a session key and setting a project (~school year) to use, we can retrieve XML data for a given resource (class/group).

Then it’s simply a matter of parsing the XML and creating an iCal with the extracted data.

I’ve again set up a cron job to generate the calendars every day; Once the calendars are uploded to the net, we can add their URL to our Google Calendar, and have an up-to-date timetable right on our phone!

 
Calendars can be found here: stic.imnotacyb.org
GitHub repo is here: github.com/JohannDickson/UDS_edt


 Update (20/01/14)
The University –finally– officially supports the export of calendars from ADE in a way that’s useful.

Posted in Software, University | Leave a comment

Jabber server with Prosody

Update: If you use Puppet, I’ve written a module for Prosody which can be found here: https://forge.puppetlabs.com/JohannDickson/prosody


I’ve recently installed a Jabber server for use within my family, it’s a great way for us to communicate since we’re split among different places, don’t really use Skype or other, and it can be more convenient than SMS or email.

So I figured I’d keep track of my installation steps, and share them here.

In preparation, you will need to set up the following DNS records:

jabber.imnotacyb.org A ...
_jabber._tcp.imnotacyb.org CNAME jabber.imnotacyb.org
_xmpp-client._tcp.imnotacyb.org CNAME jabber.imnotacyb.org
_xmpp-server._tcp.imnotacyb.org CNAME jabber.imnotacyb.org

Also open the following Firewall ports:

TCP 5222
TCP 5269

Installation:

apt-get install prosody lua-sec

I’m not going to be using ‘localhost’ configuration, so I’ll remove its configuration and keys:

cd /etc/prosody
rm conf.d/localhost.cfg.lua
rm certs/localhost.cert certs/localhost.key

Create new configuration file, based on existing example:

cp conf.avail/example.com.cfg.lua conf.avail/imnotacyb.org.cfg.lua

Certificate creation:

openssl req -new -x509 -days 365 -nodes \
 -out jabber.imnotacyb.org.crt \
 -keyout jabber.imnotacyb.org.key

Fill in the info, then put the keys in their proper location (/etc/prosody/certs/)

Modify your generic (virtualhost defaults) values in prosody.cfg.lua

nano prosody.cfg.lua

Here are the general changes I’ve done:

ssl = {
    key = "/etc/prosody/certs/localhost.key";
    certificate = "/etc/prosody/certs/localhost.cert";
}
--c2s_require_encryption = false
--s2s_require_encryption = false
c2s_require_encryption = true
s2s_require_encryption = true
authentication = "internal_plain"
authentication = "internal_hashed"

I also removed everything to do with the virtualhost and components, as these will be added on a per-site basis.

You can set your virtualhost configuration in prosody.cfg.lua if you want, but I prefer to make a separate virtualhost file:

nano conf.avail/imnotacyb.org.cfg.lua
-- jabber.imnotacyb.org

VirtualHost "jabber.imnotacyb.org"

-- admins = { "johann@jabber.imnotacyb.org" }

ssl = {
    key = "/etc/prosody/certs/jabber.imnotacyb.org.key",
    certificate = "/etc/prosody/certs/jabber.imnotacyb.org.crt",
}

modules_enabled = {
    "groups";
}

groups_file = "/etc/prosody/imnotacyb.org_groups.txt"

Component "conference.jabber.imnotacyb.org" "muc"
    name = "imnotacyb.org Conferences"
    restrict_room_creation = true

Create a symlink in conf.d to enable the virtualhost, then (re)start prosody.

Create the user accounts:

prosodyctl adduser johann@jabber.imnotacyb.org

Or for batch registrations:

prosodyctl register johann jabber.imnotacyb.org secretpassword

I’ve defined a file for groups, here’s what it looks like;

[Test group]
test@jabber.imnotacyb.org=Test
test2@jabber.imnotacyb.org
johann@jabber.imnotacyb.org=Johann

[Test group] is the name of the group; putting a + in front of the name ( such as [+Test group]) will make it a public group, viewable by everyone registered on the server.

In this example, a user will see the contact list as such:

Test group
Test
test2@jabber.imnotacyb.org
Johann

Basically, if you put a name after an address (and an = sign), the users will see that name, instead of the jabber address.

You can now do the following command to reload the server configuration:

service prosody reload

And connect using your favourite client. I personally use Pidgin on Windows, and Xabber on Android.

Posted in Linux, Software | Tagged , , | Leave a comment

Back on my wheels

Aaaah, it’s been a while now since I’ve last gone Freebording, and at that time I’d broken my wrist… that was over a year ago (2 September 2011) and I’ve only just gone back for a ride yesterday.

I went to the road that goes up to the Mont du Chat, from my place that’s 4.4km total. Luckily, when I got to the bottom of the part that only goes up to the top, a group stopped and offered me a ride up, they’d seen the board and were intrigued, and stayed a bit after to see how it goes. That first run was pretty cool, only met 2 cars in places where it was easy to avoid them and 2 cyclists I would cross again later-on. After I’d started walking up again, a couple picked me up, and then once I’d just finished that run, I hardly had the time to take my helmet off that already someone had stopped to take me up!

After that, I rode all the way down back home, it felt so nice to go for a ride like that after so long. And today, a friend was going to take some pictures by the lake and offered me a ride so he could also take some pictures of me Freebording, so I went to a nice and small spot, empty of traffic by the lakeside.

Posted in Freebord | Tagged | Leave a comment