Posts

Showing posts from 2010

Using Plink.exe from C# (accessing a linux PC)

T here seems to be a lot of questions on the web from people trying to access a linux from C#, most of them having problems using 'Plink'. This comes with 'Putty' and allows you to run remote commands on a linux machine. For this example, you have to use Putty to create and store a session using a public key. This makes automated login safer and more secure. The following code runs the 'ls' command on the remote session, called "quarch". Note the redirect of both standard in and standard out! System.Diagnostics. ProcessStartInfo ProcStart; System.Diagnostics.Process Proc; string Result; System.IO.StreamReader Output; ProcStart = new System.Diagnostics. ProcessStartInfo(@"c:\program files\putty\plink.exe"); ProcStart.Arguments = "-load quarch ls"; ProcStart. RedirectStandardOutput = true; ProcStart. RedirectStandardInput = true; ProcStart.

Accessing SD cards via SPI bus

There are various examples of accessing standard SD cards via the SPI bus (Microchip has one in their example code) but getting to the basics of how to implement your own is tricky! Here is a simple how-to, I've tried to show WHY you have to do certain things to make it clear what is happening.... - I'm assuming you have the SD card correctly connected onto the SPI bus and the chip select line (I'll call it CARD_CS) also setup correctly. [SPI BASICS] The SPI bus clock only runs while data is being clocked in/out. Data moves in both directions at the same time so if you clock 'out' byte 0xB3 you're 'in' buffer will change to whatever is on the input bus. If the device you are talking to did not send anything back at that time, the value will be 0x00. The SD card keeps things simple by (normally) not sending anything back until you have finished sending it a commend. This avoids the need to handle 'in' and 'out' comms at the same time... As

Testing on Windows 7 64 bit

If you are trying to get your current .NET code running on a 64 bit system (in my case windows 7 x64) there is a problem loading DLLs If your app needs to load a 32-bit DLL, using LoadLibrary then you'll often find that it fails and the returned pointer is always NULL! This happens if the project target is 'x64' or 'all'. You need to set the build options to build for x32 chips only. That will allow the 32 bit DLLs to be picked up again.