Writing Linux device drivers

Posted by & filed under Programming.

Nice article on writing drivers for the linux kernel.

User space. End-user programs, like the UNIX shell or other GUI based applications (kpresenter for example), are part of the user space. Obviously, these applications need to interact with the system’s hardware . However, they don’t do so directly, but through the kernel supported functions.

Kernel space. Linux (which is a kernel) manages the machine’s hardware in a simple and efficient manner, offering the user a simple and uniform programming interface. In the same way, the kernel, and in particular its device drivers, form a bridge or interface between the end-user/programmer and the hardware. Any subroutines or functions forming part of the kernel (modules and device drivers, for example) are considered to be part of kernel space.

www.freesoftwaremagazine.com/articles/dr…

Hardware Dev – Logic Analyzer & Bus Pirate

Posted by & filed under Uncategorized.

I think I wrote about the bus pirate some time ago.

A logic analyzer is a device that lets you watch digital signals in your electronics project. You can watch them real-time or log the data for later perusal. Unlike an oscilloscope, its not good for measuring analog signals – but also unlike an oscilloscope, you can track 8 signals at time! So its a good complementary tool. This logic analyzer plugs into a computer and has easy to use, cross-platform software. This makes it small, portable and inexpensive. If you ever have to to debug SPI, i2c, serial, CAN, 1-wire, Manchester, biphase or other digital protocols, this tool is essential!

adafruit.com/products/378

BusPirate: adafruit.com/products/237

Stripping trailing periods from a URL with .htaccess

Posted by & filed under Programming, Web Development.

I recently had a client of mine have a link to their website published in a online newspaper. The paper typo’d the URL and tacked a trailing . to the end of the HREF. A quick .htaccess edit resolved the issue:

Year 2038 bug

Posted by & filed under PHP, Programming.

Wow. Just got hit with this bug. It’s going to be a fairly easy fix (more on that later), but crazy none the less.

Excerpt from wikipedia:

“The year 2038 problem may cause some computer software to fail at some point near the year 2038. The problem affects all software and systems that both store system time as a signed 32-bit integer, and interpret this number as the number of seconds since 00:00:00 UTC on Thursday, 1 January 1970. The furthest time that can be represented this way is 03:14:07 UTC on Tuesday, 19 January 2038. Times beyond this moment will “wrap around” and be stored internally as a negative number, which these systems will interpret as a date in 1901 rather than 2038. This is caused by integer overflow.”

en.wikipedia.org/wiki/Year_2038_problem

I wrote a reporting system for a client of mine. It displays memberships based on their expiration date. Several members have their expiration dates set as 2046 and higher. I found that these members were being incorrectly classified by the system as expired. Hello Y2K bug all over again!

For MySQL, I found that storing dates as DATETIME rather than TIMESTAMP solves the issue. For PHP, using the DateTime API allows you to work with dates beyond 2038.

In my case, I was actually following this already by storing the dates in the database as DATETIME and using PHP’s DateTime API to process the dates. In my case the problem came into play when… I was comparing dates using strtotime():

Switched to comparing the DateTime objects and problem solved:

More Ref:
stackoverflow.com/questions/3953333/maxi… stackoverflow.com/questions/2012589/php-…