<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bits and Bricks &#187; Linux</title>
	<atom:link href="http://bitsandbricks.no/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://bitsandbricks.no</link>
	<description>The life of a female geek</description>
	<lastBuildDate>Thu, 23 Jul 2015 12:08:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.39</generator>
	<item>
		<title>Getting started with Python on EV3</title>
		<link>http://bitsandbricks.no/2014/01/19/getting-started-with-python-on-ev3/</link>
		<comments>http://bitsandbricks.no/2014/01/19/getting-started-with-python-on-ev3/#comments</comments>
		<pubDate>Sun, 19 Jan 2014 21:12:05 +0000</pubDate>
		<dc:creator><![CDATA[Cecilie]]></dc:creator>
				<category><![CDATA[LEGO]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[ev3]]></category>
		<category><![CDATA[lego]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bitsandbricks.no/?p=268</guid>
		<description><![CDATA[So I&#8217;ve been diving head first into LEGO&#8217;s newest Mindstorms generation, called EV3. But seeing as I&#8217;m a Linux geek and a programmer, using LEGO&#8217;s own graphical drag-and-drop programming language from their windows/mac software was completely out of the question! &#8230; <a href="http://bitsandbricks.no/2014/01/19/getting-started-with-python-on-ev3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>So I&#8217;ve been diving head first into LEGO&#8217;s newest Mindstorms generation, called EV3. But seeing as I&#8217;m a Linux geek and a programmer, using LEGO&#8217;s own graphical drag-and-drop programming language from their windows/mac software was completely out of the question! Now, the EV3 runs Linux out of the box, which is very cool, but it comes with some limitations, so to get going with a proper programming language, installing another Linux version was necessary. Luckily, the EV3 makes that so much simpler than the NXT did. Just pop a bootable OS on a micro SD card, stuff in the EV3, and voila, it will boot from the SD card! Pop the card back out, and the EV3 still has it&#8217;s factory firmware. No flashing needed! Neat!</p>
<p>So what programming language to use? Well, turns out some guy who calls himself Topikachu has already made a ready Linux image with Python installed, and even made Python libraries to interface with the EV3 sensors and motors. Does it get any better than that? He&#8217;s made a quick howto on how to install it, which you can read on his <a href="https://github.com/topikachu/python-ev3">github</a>. If you have a USB Wifi dongle too (currently only one is supported, but I&#8217;m sure more will be added in time), it was very easy to get it hooked up on wifi too. I just had to log in over usb as described, update the <a href="http://linux.die.net/man/5/wpa_supplicant.conf">wpa_supplicant.conf</a> and I was good to go without a cable. You may want to check out what IP your brick received before unplugging the usb cable though <img src="http://s.w.org/images/core/emoji/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The Python API is really great, but I couldn&#8217;t find much documentation of it, so I had to read his code and look at his tests to figure out how to use it. Wasn&#8217;t too hard though, and here&#8217;s a little program I wrote just to test out that things were working (it doesn&#8217;t do much, basically just tries to crash :P)</p>
<pre>#!/usr/bin/python

import time

from ev3.rawdevice import motordevice
from ev3.rawdevice import analogdevice
from ev3.rawdevice import uartdevice

from ev3 import lego

motordevice.open_device()
analogdevice.open_device()
uartdevice.open_device() 

A = 0x01
B = 0x02
C = 0x04
D = 0x08

right = A
left = D
both = A+D

touch = lego.EV3TouchSensor(0)
ir = lego.EV3IRSensor(3)
ir.set_prox_mode()

motordevice.speed(both,20)

distance = 101

while True:
  time.sleep(1)
  if touch.is_pressed() == 1:
    motordevice.stop(both, brake=1)
    print "stopping\n"
    break

  cur_distance = ir.get_distance()
  if cur_distance &gt; distance:
    print "searching\n"
    motordevice.stop(both, brake=1)
    motordevice.speed(A, 20)
    time.sleep(1)
    motordevice.stop(A, brake=1)
    motordevice.speed(both,20)

  distance = cur_distance

motordevice.stop(both, brake=1)</pre>
<p>That doesn&#8217;t look so hard, does it? Here&#8217;s some additional notes I made for myself to remember what the different functions do and how to use them.</p>
<pre>Motors:
A = 0x01
B = 0x02
C = 0x04
D = 0x08
PORTS = A+B # Access both A and B at the same time
from ev3.rawdevice import motordevice
motordevice.open_device()

motordevice.speed(PORTS,20)
motordevice.stop(B,brake=1) # brake makes it actually brake the motor, not just stop turning it

from ev3.rawdevice import analogdevice
analogdevice.open_device()
touch = lego.EV3TouchSensor(0) # Note, the port numbering is 0-3, so the port marked 1 is 0, etc.
touch.is_pressed()

from ev3.rawdevice import uartdevice
uartdevice.open_device()
color = lego.EV3ColorSensor(3)
color.set_color_mode()
color.color_to_string() # This only works for color_mode
color.set_ref_raw_mode() # raw values, -127 -&gt; 127
color.get_value() # raw value from sensor sensor

ir = lego.EV3IRSensor(2)
ir.set_prox_mode() # proximity mode
ir.get_distance() # for prox mode
ir.set_remote_mode() # for using the remote control
ir.get_remote_command() # get remote control command
ir.set_seek_mode() # follow remote control when button pressed
ir.get_all_direction_and_distance #  for seek mode
ir.get_direction_and_distance(chan) #  for seek mode

# This is how I managed to read info from a Hitechnic accelerometer sensor (originally made for the NXT)
from ev3 import robot
from ev3 import sensor
robot.open_all_devices()
iicsensor = IICSensor()
iicsensor = sensor.IICSensor(1, 0x02)
iicsensor.read(0x42)</pre>
 <img src="http://bitsandbricks.no/?feed-stats-post-id=268" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://bitsandbricks.no/2014/01/19/getting-started-with-python-on-ev3/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Wireless music &#8211; from server through phone to speakers</title>
		<link>http://bitsandbricks.no/2012/03/05/wireless-music-from-server-through-phone-to-speakers/</link>
		<comments>http://bitsandbricks.no/2012/03/05/wireless-music-from-server-through-phone-to-speakers/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 12:02:19 +0000</pubDate>
		<dc:creator><![CDATA[Cecilie]]></dc:creator>
				<category><![CDATA[Gizmos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[knots]]></category>
		<category><![CDATA[n900]]></category>

		<guid isPermaLink="false">http://bitsandbricks.no/?p=196</guid>
		<description><![CDATA[Been a while since I&#8217;ve blogged anything, guess I&#8217;ve been rather busy with getting my apartment ready for sale. One of the things we&#8217;ve done is to paint the bedroom and living room. And what better way to make that &#8230; <a href="http://bitsandbricks.no/2012/03/05/wireless-music-from-server-through-phone-to-speakers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Been a while since I&#8217;ve blogged anything, guess I&#8217;ve been rather busy with getting my apartment ready for sale. One of the things we&#8217;ve done is to paint the bedroom and living room. And what better way to make that a pleasant experience than to play some music while working? When painting the bedroom that was not a problem, we could just play music from the media center pc to the surround speakers installed in the living room. But when the time came to paint the living room, we had packed all that away, to get everything cleaned out before painting (oh, the irony :P). So what does a geek do? Go out and buy some bluetooth A2DP enabled portable mini speakers of course. But then started the fun part. The music library on my phone wasn&#8217;t what I wanted to listen to while painting, it was more suited to relaxed listening on the subway. What I wanted was to get access to my full music library on my server (located in the &#8220;server cabinet&#8221; in the kitchen). I could of course have just plugged an audio cable from said server to the speakers, but what fun is that? So I started looking for an application to my phone that could stream music from the server. Now, as you may already know, I don&#8217;t have a mainstream android phone or iphone, but a Nokia N900 with Maemo. And lo and behold, in the extras-repository, I found something called Knots. Installation seemed to be quite straightforward, just install the application on the phone, and on the server, and the only requirements besides that were a browser and VLC. No problem, right? I wish&#8230;</p>
<p>Turns out installing a compatible VLC was a bit harder than expected. Of course, everything is usually a bit harder than expected when you run Gentoo Linux. <img src="http://s.w.org/images/core/emoji/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> After many reinstalls of different versions of VLC and gradually adding more USE flags, I finally found a combination that worked. Apparently, Knots uses a telnet interface in VLC that they have abandoned. In VLC 1.1.x it was still available with the format &#8220;oldtelnet&#8221; (which Knots supported using if configured to use with VLC 1.1.x), but no such luck with VLC 2.x. Maybe it&#8217;s still in there, I don&#8217;t know, but it must be under a different name if it is. So, in the unlikely event that somebody else out there is trying to use Knots in Gentoo Linux and is struggling with this, here is the final VLC install:<br />
<code>media-video/vlc-1.1.13  USE="X ffmpeg gcrypt httpd lua mmx mp3 ncurses ogg qt4 sqlite sse theora vlm vorbis xcb xml"</code><br />
The USE flags of note here that I had to add for it to work are httpd, lua, xml and vlm.</p>
<p>After that, it was just a matter of getting my phone on the correct WLAN (for some reason, it kept choosing the one named &#8220;linksys&#8221; belonging to a neighbour :P), and turn off the silent profile on the phone (for some reason, Knots didn&#8217;t make i single sound when the phone was in the silent profile, even though the inbuilt music player couldn&#8217;t care less about that, oh well. Just caused me some confusion). I should maybe note, however, that even though Knots worked fine, it wasn&#8217;t as good as I&#8217;d hoped. A few features I missed were the possibility to just add everything to the playlist, and then shuffle said playlist. I had to settle for either the &#8220;random&#8221; feature, which just selected a (not very large) number of songs randomly from the library, or add some songs matching a search to a playlist, but then they couldn&#8217;t be shuffled. I just ended up using the &#8220;random&#8221; feature, and just go and select a new set of random songs every time it stopped.</p>
 <img src="http://bitsandbricks.no/?feed-stats-post-id=196" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://bitsandbricks.no/2012/03/05/wireless-music-from-server-through-phone-to-speakers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>If Linux was a car</title>
		<link>http://bitsandbricks.no/2011/10/24/if-linux-was-a-car/</link>
		<comments>http://bitsandbricks.no/2011/10/24/if-linux-was-a-car/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 11:52:04 +0000</pubDate>
		<dc:creator><![CDATA[Cecilie]]></dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://bitsandbricks.no/2011/10/24/if-linux-was-a-car/</guid>
		<description><![CDATA[I came across this blog post that imagines how it would go if someone with the typical Linux-hater attitude had the same attitude towards cars. Quite a funny read If Linux was a car (Hater’s edition) &#124; Michael Hall&#8217;s Blog]]></description>
				<content:encoded><![CDATA[<p>I came across this blog post that imagines how it would go if someone with the typical Linux-hater attitude had the same attitude towards cars. Quite a funny read <img src="http://bitsandbricks.no/wp-includes/images/smilies/simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br /><a href="http://mhall119.com/2011/10/if-linux-was-a-car-haters-edition/">If Linux was a car (Hater’s edition) | Michael Hall&#8217;s Blog</a><br />
<blockquote></blockquote>
 <img src="http://bitsandbricks.no/?feed-stats-post-id=170" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://bitsandbricks.no/2011/10/24/if-linux-was-a-car/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
