After many months I got my Raspberry Pi in the mail. Even though I've seen many pictures of it, it still looks much smaller than I thought. If you don't know what a Raspberry Pi is, its a tiny computer about the size of a deck of cards. Its just the board through, no fancy case. It also has a bunch of extra pins on it so you can do some I/O, like reading switches and setting LEDs. You also need to supply your own power supply and memory card.
I used my USB phone charger cable to power it. I've read some phone cables don't work, but this one seems to work, so far. I copied the Debian image from the Raspberry Pi website on to the memory card and booted up with no problem. Next I looked for something interesting to try out. I found this post about streaming Pandora music. I followed it and was able to connect to Pandora, but the music would stop after a second or two. Turns out there was a bug in the ALSA (sound) drivers. If you background the task (Ctrl-Z) and then foreground it again (fg), it would play for a few more seconds. I next tried the beta Debian image on the Raspberry Pi website, since it was newer. It still had the problem. After a a little google search I found this. Apparently they just fixed the driver a few days ago. To update the firmware I used Hexxah's raspi-update tool. Just had to run it and reboot when it finishes. I tried pianobar and it work that time.
Next was the GPIO pins. They are perfectly spaced out for an old ribbon cable. I first tried and IDE cable but realized it was one of the UMA 66 with extra conductors in it. Rather than chance anything funny with that cable I found an old floppy drive cable. It fits over the pins with the last 4 rows sticking out. I then wired an old bread board I had to an LED and switch using this diagram. I next used the RPi.GPIO library and wrote a script to toggle the LED on the switch. The LED was a little dim the for the first test, so I swapped the resistor for a smaller one and its much brighter now.
Something of note, I had used the wrong pin diagram incorrectly wired the wrong GPIO to the switch, and the Pi instantly turned off. Thought I had blown something, but after only minute of being off it came back up fine. Another thing to know is the GPIO to turn a LED on is TRUE and FALSE to turn it off, while reading a switch is TRUE when its open and FALSE when its closed.
If any cares I can post pictures.
Sunday, June 24, 2012
Friday, April 13, 2012
Old server is gone
I used to have a CoLocated server. Its no longer co-located anywhere with internet, so its doing me no good. It used to run my blog, but I have since switch over to here. One of the popular posts on it was about my old Acer laptop having a WHITE SCREEN OF DEATH. Basically the computer would only show a White screen when you powered it on.
The solution is to open the panel on the top right side above the keyboard. This is where the LCD screen connects to the mother board. The ribbon cable is only held in with some tape and can easily become loose. When it does, the screen will go white. Just push the connection all the way back on and secure it with something better. I used some blue painter tape. Some people have noticed the round toroid on the ribbon cable. This is supposed to be there. It is to filter the signal LCD screen. Do not remove it.
4 HD Tuners
Months ago I bought a ceton 4 tuner HD card. Its been sitting in my computer picking up over the air HD channels. Though nice, it wasn't using the full potential of the card. I finally call the cable company to get someone out to install a CableCard and Network tuner. Technically, they are required to let me do this for free, but insisted on sending someone out and charger us for it. Mainly because they have issues with CableCards not working the first time.
The CableCard worked the first time and I was able to pick up cable channels on the card. A small issue happened when tried to watch the HD channels. Seems all the HD channels use SDV (switched digital video). To watch SDV channels, you need a tuner adapter. Because there are so many cable channels now, they can't send them all down the pipe at the same time. The tuning adapter is an extra box that connects via USB to the computer. The computer tells it which channel you want to watch and it reports back what frequency that channel will show up on.
The tuner adapter did not connect to the computer the first day, or the second. I opened a ticket with Ceton about it, they were quick to respond and had me send a few diagnostic logs. Then, a few days later it just started working on its own. Might have had to do with the fact the computer finally auto installed SP1 on it.
Now that its working correctly, I have to say its pretty nice. I'm able to watch 1 channel and record 3 others at the same time. I can even share the tuners over the network so other computers can watch tv too.
Some things I'm sad about. Media Center will not allow you to watch 2 channels at the same time, ala Picture in Picture. The hard drive in the computer is TOO small. I used an old 80gb laptop one I had laying around. This is not even close to what you need when recording HD video.
Monday, October 3, 2011
Classes and DLLs
DLLs are libraries with named functions in them. Usually the names are human readable. C++ has this thing in it call named mangling. This is to allow for overloaded functions and other things. When you build a C++ DLL, all the functions will be exported as their mangled names. Every compiler mangles differently. This isn't a problem if you use the LIB file, because the compiler will automatically link to the correct mangled name in the DLL. This requires that you be statically linked to the DLL, and that it be compiled with the same compiler. If you want to load DLLs at runtime using LoadLibrary, you will need to know the mangled name for use with GetProcAddress. So all this gets complicated really fast.
There is a simple way around this using a factory method. Take for example DirectX. You call Direct3DCreate9 to get pointer to a IDirect3D9 object. Instead of calling "new Direct3D9()", you call the factory method. Instead of calling "delete obj" you call Release.
To do this, you have to follow a few rules. You must use the factory method to create, and use the release method delete. This is to keep the memory allocator happy.
You can expand on the factory method by passing in an argument to select the type of object to return.
MyObject* obj = (MyObject*) CreateObject( MY_OBJECT_TYPE );
CreateObject figgures out the correct object to create/return based on the supplied argument. The supplied argument could be an enum if you are returning a fix number of known object types. You could alternatively pass in a string to match against and build a look up table to match against.
hmod = LoadLibrary("some.dll");
Fn CreateObject = (void* (*(char*)) )GetProcAddress( hmod, "CreateObject");
CreateObject("MyObject);
There is a simple way around this using a factory method. Take for example DirectX. You call Direct3DCreate9 to get pointer to a IDirect3D9 object. Instead of calling "new Direct3D9()", you call the factory method. Instead of calling "delete obj" you call Release.
To do this, you have to follow a few rules. You must use the factory method to create, and use the release method delete. This is to keep the memory allocator happy.
You can expand on the factory method by passing in an argument to select the type of object to return.
MyObject* obj = (MyObject*) CreateObject( MY_OBJECT_TYPE );
CreateObject figgures out the correct object to create/return based on the supplied argument. The supplied argument could be an enum if you are returning a fix number of known object types. You could alternatively pass in a string to match against and build a look up table to match against.
hmod = LoadLibrary("some.dll");
Fn CreateObject = (void* (*(char*)) )GetProcAddress( hmod, "CreateObject");
CreateObject("MyObject);
Monday, September 26, 2011
New DVR
Ordered a Centon Infinitv. For those who don't know, its a PCIe card for your computer that allows you to record up to 4 digital (HD) cable channels. So now I can set up to 4 shows to DVR at once. Only needed to run the setup and restart the computer. Windows Media Center picked it up right away as 4 tuners. The longest part was waiting for all the channels to be found.
One feature that is really cool is being able to use the extra tuners on other PC's on the network. Ceton refers to this as 'network tuners'. Requires you to install software on both computers and to have a fairly fast network. I tried it over 54mb wireless. The software warns against this but I tried anyways. It worked, but saturated my wireless. Using a full 100mbit or gigabit would probably work just fine.
The only problem with digital cable is you need a M-Card from the cable company. This requires a service tech to come out to install/activate one. As far as I can tell, they are required to come out because you aren't guaranteeing a card will work the first time. I still need to schedule that, since summer seems to be the busiest time, its hard to get one to come out
One feature that is really cool is being able to use the extra tuners on other PC's on the network. Ceton refers to this as 'network tuners'. Requires you to install software on both computers and to have a fairly fast network. I tried it over 54mb wireless. The software warns against this but I tried anyways. It worked, but saturated my wireless. Using a full 100mbit or gigabit would probably work just fine.
The only problem with digital cable is you need a M-Card from the cable company. This requires a service tech to come out to install/activate one. As far as I can tell, they are required to come out because you aren't guaranteeing a card will work the first time. I still need to schedule that, since summer seems to be the busiest time, its hard to get one to come out
Friday, August 26, 2011
"Shims" in C++/CLI
I saw this post about writing a plugin DLL for the Optimus Mini Three. The DLL needs to be written in C++ but what if you wanted to write it in .NET (ie C#). C# doesnt allow you to directly write normal DLLs that C++ can call into. Instead you need what is called a "shim". A little piece of glue code.
Here is some example glue code to create a plugin for the Mini Three
#define WIN32_LEAN_AND_MEAN #include "windows.h"
#include "OptPlugin.h"
#include <vcclr.h>template<typename T>
class Shim : public OptimusMiniPlugin {
gcrootobj;
public:
Shim(int f) { obj = gcnew T(f); }
virtual BOOL __stdcall Paint(HDC hdc){ return obj->Paint( IntPtr(hdc) ); }
virtual void __stdcall OnKeyDown(){ obj->OnKeyDown();}
virtual LPARAM __stdcall GetInfo(int index) {
#ifdef _WIN64 return obj->GetInfo(index).ToInt64();#else return obj->GetInfo(index).ToInt32();#endif}
};
PLUGIN_EXPORT(Shim)
"Shim" is a C++ class while SomeDotNetClass is a managed class. PLUGIN_EXPORT is the provided macro from Optimus to create the plugin exports. The key to this is the gcroot. It allows you to reference a managed object from the non-managed class. You then just forward call your calls to the managed class. Create your managed class in a C# assembly and reference it from the C++ dll.
Thursday, August 25, 2011
Macros in C#
Macros are a wonder feature found in C++. It allows you to write a template of sorts and use throughout. I bet you didn't know C# allows for templates too.
<#@ template language="C#" #>
// This code was generated by a tool.
// Any changes made manually will be lost
// the next time this code is regenerated.
using System;
public class <#= this.ClassName #>
{
public static void SayHello()
{
Console.WriteLine(”Hello World”);
}
}
<#+
string ClassName = "MyClass";
#>
There is a wonderful template library built in to visual studio called T4. Just add a new file to your project and change the extension to ".tt"
<#@ template language="C#" #>
// This code was generated by a tool.
// Any changes made manually will be lost
// the next time this code is regenerated.
using System;
public class <#= this.ClassName #>
{
public static void SayHello()
{
Console.WriteLine(”Hello World”);
}
}
<#+
string ClassName = "MyClass";
#>
When you compile this will make a ".cs" file of the same name automatically. These templates are much more powerful than C macros. You have full access to any assemblies in the GAC (for example XML, Networking, and IO).
For more examples see http://msdn.microsoft.com/en-us/data/gg558520
Subscribe to:
Posts (Atom)