Code Blog

Displaying 1-5 of 6 results.
2016/09/28 MacOSX

I started to get some battery warnings in Mac OS X and before long the battery was not working at all (when I unplugged the power cable the computer turned off immediately even though the battery should have been fully charged). I bought a Llano replacement battery online from TMall for 279 RMB. It has a 7150 mAh capacity. The price included shipping and the two torx screwdrivers needed for changing the battery.

To make sure I got the correct battery I checked the model number on the back of my Macbook Air (mid-2013) (mine says "Model A1466" on the back).

There's a good step-by-step instruction on Youtube for changing battery in a Macbook Air:
https://www.youtube.com/watch?v=SsyIT28wirs

2016/09/25 Raspberry-Pi

The new Raspberry Pi 3

As I wrote in a previous post my Raspberry Pi 2 stopped working. So I ordered a new one, but this time the newer Raspberry Pi 3 model. I posted some photos below of the new board and comparing it with Raspberry Pi 2. One new feature is that Raspberry Pi 3 comes with wifi and bluetooth built-in. The Raspberry Pi 3 has a 1.2 GHz quad-core 64-bits CPU compared with Pi 2's 900 MHz quad-core 32-bits CPU. The GPU is also faster for the Raspberry Pi 3 (400 MHz compared to 250 MHz). Both have 1 GB RAM. Overall the Pi 3 is quite a bit faster than its previous model.

Photos of the Raspberry Pi 2 Model B (bottom) and my new Raspberry Pi 3 Model B (top). As can be seen from the photo the form factor is exactly the same between rpi2 and rpi3, so the old case can be reused if needed.

I didn't know before buying the new Pi 3 but it seems that Raspberry Pi 3 is known for running even hotter than Raspberry Pi 2 (makes sense with higher clock speeds). So I will need to take some precaution to not let it run too hot this time.

I made a surprising discovery when taking the rpi2 out of it's case: The heat sink had moved off the CPU! Maybe it had came loose when falling down some time? This for sure didn't help it stay cool .. Maybe this is an issue with really really cheap heat sinks from China ..

So I got some new (cheap) heat sinks for the Raspberry Pi 3.


Installed the heat sinks on the new board

Installation

I got a new SD-card and reinstalled Volumio. There are a lot of good articles online describing how to set up Volumio, for example https://bkmjournal.wordpress.com/2014/08/16/convert-your-raspberry-pi-into-an-audiophile-music-player-using-volumio/ 

Quick breakdown of what Volumio is:

Volumio = Raspbian + Media Player Daemon (MPD) + samba web server + support for a large list of USB digital audio codecs (DACs)

Where Raspbian is a Debian-based OS for the Raspberry Pi. Raspbian is now official provided by the Raspberry Pi Foundation as the primary OS for the Raspberry Pi.

Downloaded a new version of Volumio from https://volumio.org/ 

Version: 0.979 (Release date 20-08-2016) - 286 MB

The version numbers are a bit confusing to say the least. I had Volumio version 1.55 installed on my Raspberry Pi 2 before. It doesn't really say so on their website but this version that I've downloaded is version 0.979 of "Volumio 2". So "Volumio" and "Volumio 2" is not the same thing. I think it would have been more logical and a lot less confusing to call it version 1.979 instead.

The Volumio website has step-by-step user instructions for installing it. Its all very easy, just download the image file and write it to the SD card. Then insert the SD into Raspberry Pi board and boot it up. Volumio recommends using https://www.etcher.io/ to write the SD card. I had PiWriter installed since before but it doesn't seem to work that well with Mac OS X El Capitan so I'll use etcher instead.

To connect to volumio type volumio.local in web browser (on same physical network) and you get a UI for controlling the music. I have an iOS app installed on my phone called MPoD that can connect to volumio so I usually use that to control the music.

For the parts from my old Raspberry Pi 2 it turns out both the SD card was corrupt and worse - the audio I2S card was broken too. So the I2S card needs to be replaced as well. I have to test the Raspberry 2 Pi board later, maybe its still ok with a new SD card. 

I2S is a communication protocol specifically designed for digital audio data. From Wikipedia:

I2S, also known as Inter-IC Sound, Integrated Interchip Sound, or IIS, is an electrical serial bus interface standard used for connecting digital audio devices together. It is used to communicate PCM audio data between integrated circuits in an electronic device. The I2S bus separates clock and serial data signals, resulting in a lower jitter than is typical of communications systems that recover the clock from the data stream.

I2S is used in for example CD players, connecting the reading mechanism to the DAC and/or the S\PDIF output. I2S is also used on every standalone DAC.

There's a good article about advantages for using a I2S card at https://volumio.org/raspberry-pi-i2s-dac-sounds-so-good/. As my I2S card was broken I tried to connect speakers directly to the built-in stereo plug of the Raspberry Pi but the sound volume was extremely low, so couldn't really use that at all.

ssh volumio.local
username: volumio password: volumio
sudo nano /etc/modules
snd_soc_bcm2708
snd_soc_bcm2708_i2s
bcm2708_dmaengine
snd_soc_pcm5102a
snd_soc_hifiberry_dac
/boot/config.txt
uname -a
Linux volumio 4.4.9-v7+ #884 SMP Fri May 6 17:28:59 BST 2016 armv7l GNU/Linux

System update

It is a good idea to run upgrade your system after initial setup using the following commands:

sudo apt-get update
sudo apt-get -y upgrade

This will update components of the Rasbian OS even if you have picked up the latest release of volumio. The "-y" flag means answer automatic yes for all prompts when installing the detected updates.

Backup SD card

Its recommended to make a backup of the SD card once the Pi is finished configuring. This will save you a lot of time if your image gets corrupt (tends to happen with the Pi). Remove the SD card from the device and connect it to your PC. Use the Win32DiskImager tool to create a backup. Use the read option to create an image from the SD card.

 

 

 

2016/09/19 MacOSX,Xcode

The Apple developer download page normally redirects to the Apple Store for downloads, but the link below is quite handy to get direct links for downloading (you need to be logged in as developer first)

https://developer.apple.com/download/more/

I often have trouble in China downloading Xcode as the network usually gives up before the download is completed (Xcode 8 is 4.1 GB).

The latest Xcode 8 is right now only available as a .xip file (not .dmg). The .xip file format contains an archive (xar containing a gzip archive and metadata) and a signature of the archive. You can open/extract it with the Archive Utility.app in finder. If you want to investigate whether the .xip is validly signed you can use pkgutil:

pkgutil --check-signature Xcode_8.xip
2016/09/19 MacOSX

To list all USB devices (with device information) run the following command in terminal window:

system_profiler SPUSBDataType

Another way is to use the "ioreg" that is a command line tool to show I/O kit registry. By default it clips to the window's width (i.e. 80 chars) so you may add the -w0 flag to get a full-width display.

ioreg -p IOUSB -w0

Adding the -l flag will show full details about each devices.
If you only want to list the device names, you can filter away all other information with this line:

ioreg -p IOUSB -w0 | sed 's/[^o]*o //; s/@.*$//' | grep -v '^Root.*'

Information from post by Gordon Davisson (http://apple.stackexchange.com/users/427/gordon-davisson)

2016/09/19 MacOSX

Tip 1: Change screenshot file type:

defaults write com.apple.screencapture type jpg

Tip 2: Encrypt and decrypt file using openssl:

openssl enc -aes-256-cbc -e -in {path-in} -out {path-out}
openssl enc -aes-256-cbc -d -in {path-in} -out {path-out}

Tip 3: Set updates check to daily (or any other value you would like)

defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

Tip 4: Hold down option key when clicking on volume icon to quickly switch between audio input and output devices.

Tip 5: Prevent computer to sleep / install updates:

caffeinate -i -t 3600

Source:
https://www.youtube.com/watch?v=uI4x0wvogco
http://snazzylabs.com/tutorial/five-advanced-tricks-for-mac-users/