I previously wrote about my fiddling with lcdproc and tip to get characters to display. After much initial failure, I finally got a working LCDd.conf for lcdproc. For the impatient, here it is:
[server]
Driver=MtxOrb
DriverPath=/usr/local/lib/lcdproc/
Hello=" Hello World "
Hello=" 2013 "
ServerScreen=no
Heartbeat=off
[MtxOrb]
Device=/dev/cua01
Size=16x2
Type=lkd
Speed=19200
hasAdjustableBacklight=no
The device is an old Matrix Orbital LK162-12. The technical reference is here. It took me some time with ktrace/kdump and the technical reference to figure out that the LCDd.conf Type= should be lkd, not the default lcd. It looks like the LCDd at every refresh interval sends out "backlight on," "GPO off," and "underline off," commands. On this screen, the "GPO off," command requires an extra argument as it has 6 GPOs, so the 0xFE part of the "underline off," command was getting chomped, leaving a bare K on the LCD in various places.
Friday, September 13, 2013
Tuesday, September 10, 2013
More on frankenrouter (the Netscaler reboot as OpenBSD)
Well, I had to shelf this project for a while, but back in full force, today.
Today's problem took me most of the day to figure out. This is yet another one of the "both CARP servers are masters," issues that seem to plague CARP newbies.
If you're configuring from /etc/hostname.carp0, and you like to bust your ifconfig statements into multiple lines, you may find that you need to put all the little CARP things ahead of the plumbing of the actual IP address. To wit, this config just wasn't working for me:
inet 192.168.0.1 255.255.255.0 192.168.0.255
-inet6
carpdev em2
vhid 1
pass gandalf
However, this one works fine:
-inet6
carpdev em2
vhid 1
pass gandalf
inet 192.168.0.1 255.255.255.0 192.168.0.255
Today's problem took me most of the day to figure out. This is yet another one of the "both CARP servers are masters," issues that seem to plague CARP newbies.
If you're configuring from /etc/hostname.carp0, and you like to bust your ifconfig statements into multiple lines, you may find that you need to put all the little CARP things ahead of the plumbing of the actual IP address. To wit, this config just wasn't working for me:
inet 192.168.0.1 255.255.255.0 192.168.0.255
-inet6
carpdev em2
vhid 1
pass gandalf
However, this one works fine:
-inet6
carpdev em2
vhid 1
pass gandalf
inet 192.168.0.1 255.255.255.0 192.168.0.255
Tuesday, July 30, 2013
Turning an old NetScaler into something useful
A couple of years ago, we picked up a pair of used NetScaler NS7000s. We had them in service for a while, but eventually they became obsolete - we didn't have a NetScaler support contract, and there were new features we needed. So, we replaced the old NetScalers with a different solution.
Last week, I hit upon an idea for a new project, and the NS7000s with their 8 onboard NICs was a perfect hardware platform for me.
For those that don't know, NetScalers run FreeBSD under the hood. These particular units were running something from the 4.x series. For comparison, the current release version as of this post is 9.1.
These units boast a single Pentium 4 2.8GHz processor and 1 GB of RAM. They have dual onboard SATA ports, a single hot-plug 3.5 inch hard drive bay, and the primary IDE is jacked into a CompactFlash reader. There is also an onboard CF jack, but I have not fiddled with it; presumably, this is the second IDE channel. The two COM ports are attached to the serial console and the LCD display, respectively.
Step one was to try and recover any useful information from the old hard drives and CF cards. Bit rot had set in, though, and of the 4 units, only one hard drive was readable. Not much useful stuff, there - apparently the NetScaler products have root on the CF and /var on the hard drive.
So, I sourced new hard drives and CF cards and got to work.
Day one, I downloaded OpenBSD 5.3 x86 and performed a clean install to a hard drive. I made a little /etc/rc.local script goodness to capture the output of dmesg to a text file.
I placed the hard drive into one of the NetScalers and fired it up. I was a little concerned, initially, that the LCD still said Booting... So, I let the unit sit for about an hour. Then, I took the hard drive back out and mounted it up somewhere that I could look at the dmesg output.
SUCCESS! The box booted clean and I could see em0 - em7 listed.
Next step was to identify each interface and get one plumbed up. This was something of a trial-and-error effort. I eventually gave up, broke down and purchased a new serial cable so I could get on the console.
Once logged in to the console, building the physical jack to interface map was pretty easy. On both units, I got the same map, which looks like this (YMMV):
The next piece was to get NS7000 Booting... off the LCD console. Luckily, it was a well documented piece of hardware from Matrix Orbital. Unfortunately, I haven't been able to get any of the sample code or LCDproc to work with the unit, but I can use tip to connect via the terminal and put characters on the display, so it's just a matter of time.
Last week, I hit upon an idea for a new project, and the NS7000s with their 8 onboard NICs was a perfect hardware platform for me.
For those that don't know, NetScalers run FreeBSD under the hood. These particular units were running something from the 4.x series. For comparison, the current release version as of this post is 9.1.
These units boast a single Pentium 4 2.8GHz processor and 1 GB of RAM. They have dual onboard SATA ports, a single hot-plug 3.5 inch hard drive bay, and the primary IDE is jacked into a CompactFlash reader. There is also an onboard CF jack, but I have not fiddled with it; presumably, this is the second IDE channel. The two COM ports are attached to the serial console and the LCD display, respectively.
Step one was to try and recover any useful information from the old hard drives and CF cards. Bit rot had set in, though, and of the 4 units, only one hard drive was readable. Not much useful stuff, there - apparently the NetScaler products have root on the CF and /var on the hard drive.
So, I sourced new hard drives and CF cards and got to work.
Day one, I downloaded OpenBSD 5.3 x86 and performed a clean install to a hard drive. I made a little /etc/rc.local script goodness to capture the output of dmesg to a text file.
I placed the hard drive into one of the NetScalers and fired it up. I was a little concerned, initially, that the LCD still said Booting... So, I let the unit sit for about an hour. Then, I took the hard drive back out and mounted it up somewhere that I could look at the dmesg output.
SUCCESS! The box booted clean and I could see em0 - em7 listed.
Next step was to identify each interface and get one plumbed up. This was something of a trial-and-error effort. I eventually gave up, broke down and purchased a new serial cable so I could get on the console.
Once logged in to the console, building the physical jack to interface map was pretty easy. On both units, I got the same map, which looks like this (YMMV):
PHY | INTI was using a gigabit switch to talk to the unit. All of the interfaces showed up at 1000baseT when I plugged them in, and herein lies the first real curiosity of this platform. I was only able to get 1/7 and 1/8 to ping reliably. The other ports had major packet loss and tremendous response times. A close inspection of the front bezel shows jacks 1/1 - 1/6 are marked FE (fast ethernet), with 1/7 and 1/8 marked GB. With this in mind, I tried massaging the interfaces down to 100baseTX and voila! Working ports 1/1 - 1/6.
---------
1/1 | em3
1/2 | em0
1/3 | em5
1/4 | em4
1/5 | em7
1/6 | em6
1/7 | em1
1/8 | em2
The next piece was to get NS7000 Booting... off the LCD console. Luckily, it was a well documented piece of hardware from Matrix Orbital. Unfortunately, I haven't been able to get any of the sample code or LCDproc to work with the unit, but I can use tip to connect via the terminal and put characters on the display, so it's just a matter of time.
Labels:
FreeBSD,
LCD,
Matrix Orbital,
NetScaler,
OpenBSD
Thursday, February 2, 2012
Getting OpenVAS running on Ubuntu 11.10
A couple of quick hints, basically an unofficial update to the official installation instructions located here.
The correct add-apt-repository command is:
You will need to go into the "Manage Repositories" screen an uncheck the "Source" repository that was automagically added. I'm sure there's a fancy command for this, but again, going with what works, here. You must do this prior to the apt-get update command.
The correct add-apt-repository command is:
add-apt-repository "deb http://download.opensuse.org/repositories/security:/OpenVAS:/STABLE:/v4/xUbuntu_11.10/ ./"
I didn't bother to find the correct GPG key, though; I skipped the key import and used the "force" option with apt-get update.You will need to go into the "Manage Repositories" screen an uncheck the "Source" repository that was automagically added. I'm sure there's a fancy command for this, but again, going with what works, here. You must do this prior to the apt-get update command.
Wednesday, February 1, 2012
3d laser scanning
So, have you ever looked at a trinket on your desk and said, "hey, that would be cool to have in Second Life?"
Well, with a little persistence, you can pretty much do it for free. Assuming you already have a decent webcam, a laser pointer, and a wine glass, you're ready to roll. The rest of this post is extremely unorganized, and I have no pictures to share (yet).
First, snatch the software. You'll need Blender and DAVID-Laserscanner 3, both of which are free downloads. DAVID will operate just fine in free mode in a resolution that is far superior to anything you'll be able to put into a sculptie. Read the DAVID instructions carefully, but, truthfully, it's not hard at all.
I'm just getting past the proof-of-concept phase, so not much to report. My first scans were with the guts of an old Black & Decker Bullseye, but I've graduated to this 532nm green laser I picked up off Amazon for about $8. The wine stem method works great - just shine the pointer through a clean, thin glass or crystal wine stem to get a nice, thin lased line.
Depending on my success, I'm going to upgrade to a dedicated laser line generator, which I'll probably be grabbing from Aixiz. If you're curious how lasers compare to each other, I found a neat tool here.
Well, with a little persistence, you can pretty much do it for free. Assuming you already have a decent webcam, a laser pointer, and a wine glass, you're ready to roll. The rest of this post is extremely unorganized, and I have no pictures to share (yet).
First, snatch the software. You'll need Blender and DAVID-Laserscanner 3, both of which are free downloads. DAVID will operate just fine in free mode in a resolution that is far superior to anything you'll be able to put into a sculptie. Read the DAVID instructions carefully, but, truthfully, it's not hard at all.
I'm just getting past the proof-of-concept phase, so not much to report. My first scans were with the guts of an old Black & Decker Bullseye, but I've graduated to this 532nm green laser I picked up off Amazon for about $8. The wine stem method works great - just shine the pointer through a clean, thin glass or crystal wine stem to get a nice, thin lased line.
Depending on my success, I'm going to upgrade to a dedicated laser line generator, which I'll probably be grabbing from Aixiz. If you're curious how lasers compare to each other, I found a neat tool here.
Looking for a good alarm tone?
Looking for a nice, loud alarm clock sound for your phone? I've been using one of these ringtones from 808 State for several months, now. Bonus - they have loads of free tunes on this page.
Tuesday, November 30, 2010
A Browser in Korn
Here's a quick tcpclient how-to implementing a simple web browser:
#!/usr/local/bin/ksh
printf "GET / HTTP/1.1\r\n" >&6
printf "Host: www.blogger.com\r\n" >&6
printf "User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.4) Gecko/20100630 Firefox/3.6.4\r\n" >&6
printf "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" >&6
printf "Accept-Language: en-us,en;q=0.5\r\n" >&6
printf "Accept-Encoding: gzip,deflate\r\n" >&6
printf "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" >&6
printf "Keep-Alive: 115\r\n" >&6
printf "Connection: close\r\n" >&6
printf "Cookie: name=value\r\n\r\n" >&6
while read -u7 input; do
echo $input
done
Save that into a file called http.sh then issue forth the incantation:
$ /usr/local/bin/tcpclient www.blogger.com 80 ./http.sh || echo connection died
printf "GET / HTTP/1.1\r\n" >&6
printf "Host: www.blogger.com\r\n" >&6
printf "User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.4) Gecko/20100630 Firefox/3.6.4\r\n" >&6
printf "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" >&6
printf "Accept-Language: en-us,en;q=0.5\r\n" >&6
printf "Accept-Encoding: gzip,deflate\r\n" >&6
printf "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" >&6
printf "Keep-Alive: 115\r\n" >&6
printf "Connection: close\r\n" >&6
printf "Cookie: name=value\r\n\r\n" >&6
while read -u7 input; do
echo $input
done
Save that into a file called http.sh then issue forth the incantation:
$ /usr/local/bin/tcpclient www.blogger.com 80 ./http.sh || echo connection died
Thursday, November 11, 2010
Poor man's geocoder
Many addresses can be interpolated from the Census Bureau's TIGER/Line data. Unfortunately, the TIGER database is woefully incomplete, right now, though the LUCA program may add a bunch of data for us. Expect to see that release (the 2010 shapefiles) in March, 2011. In my testing, I was able to assign tlids to anywhere from 60% to 85% of my input of DPV-confirmed addresses, so if you're looking for better coverage... this solution is not for you.
The rough steps to geocode an address are these:
1) Get the appropriate TIGER/Line shapefile from the Census. You need to get the county All Lines file, as this is the one which has points with latitude and longitude.
2) Convert the shapefile for easier access (optional); rather than deal with learning a GIS system, such as GRASS, I opted to load the shapefile data into MySQL. I used PERL and the CPAN library called Shape to parse the shapefiles into flat files that I could load into MySQL. I went all relational and created two tables - the first is called shape_record, and is essentially unique to TIGER/Line ID (tlid). This table contains the ZIP Codes, street names, and address range information. The second table is shape_detail, is related to the shape_record on tlid. shape_detail contains each of the vertices of the TIGER/Line along with their latitude and longitude.
3) Fairly important step, here, is to standardize the data on each side of your operation. The field with the street name in it has some irregularities, and your input address may also need some cleaning up.
4) Enter the shape_record table looking for your street name and ZIP code. Narrow the result set to those tlids which have addresses which surround yours. Note that you may have more than one tlid for a single input address.
5) Enter the shape_detail table placing these records (generally at least two) into an array. These are the points of your street. Interpolate as appropriate - this part is easier expressed in code, so here's my hack-job in PHP:
$res = mysql_query( $sql, $conn );
if ( $res )
{
while ( $row = mysql_fetch_assoc( $res ) )
{
$verts[$row['vertid']] = array( 'lat' => $row['lat'], 'lng' => $row['lng'] );
}
mysql_free_result( $res );
// get the line segments;
//calc total line length;
$lines = array();
for ( $i = 1; $i < sizeof( $verts ); $i++ )
{
$lines[] = array(
'length' => sqrt(
( abs( $verts[$i]["lng"] - $verts[$i-1]["lng"] ) * abs( $verts[$i]["lng"] - $verts[$i-1]["lng"] ) )
+
( abs( $verts[$i]["lat"] - $verts[$i-1]["lat"] ) * abs( $verts[$i]["lat"] - $verts[$i-1]["lat"] ) )
),
'segments' => 0,
'verta' => $i - 1,
'vertb' => $i
);
}
$streetlen = 0;
for ( $i = 0; $i < sizeof( $lines ); $i++ )
{
$streetlen += $lines[$i]['length'];
}
// calculate the number of house-points ( tohn - fromhn )
$segments = abs( $_REQUEST['fromhn'] - $_REQUEST['tohn'] );
$seglen = $streetlen / $segments;
$togo = abs( $_REQUEST['fromhn'] - $_REQUEST['number'] );
for ( $i = 0; $i < sizeof( $lines ); $i++ )
{
$lines[$i]['segments'] = $lines[$i]['length'] / $seglen;
$togo -= $lines[$i]['segments'];
if ( $togo < 0 )
{
$togo += $lines[$i]['segments'];
$selected_line = $i;
break;
}
}
//now we have a two points, establishing a line, and a third value which represents a vector along the line from the first point
//calculate the point at the end of the vector.
$longdiff = abs( $verts[ $lines[$i]['verta'] ]['lng'] - $verts[ $lines[$i]['vertb'] ]['lng'] );
$latdiff = abs( $verts[ $lines[$i]['verta'] ]['lat'] - $verts[ $lines[$i]['vertb'] ]['lat'] );
if ( $verts[ $lines[$i]['verta'] ]['lng'] > $verts[ $lines[$i]['vertb'] ]['lng'] )
{
//going west
$longoper = -1;
}
else
{
//going east or nowhere
$longoper = 1;
}
if( $verts[ $lines[$i]['verta'] ]['lat'] > $verts[ $lines[$i]['vertb'] ]['lat'] )
{
//going south
$latoper = -1;
}
else
{
//going north or nowhere
$latoper = 1;
}
if ( 0 == $longdiff * $latdiff )
$angle_a = 0;
else
$angle_a = atan( $longdiff / $latdiff );
$angle_b = M_PI - ( ( .5*M_PI ) + $angle_a );
$angle_c = .5 * M_PI;
$togo *= $seglen; //this is the hypotenuse
$side_b = $togo * sin( $angle_b ); //this is our new latitude offset
$side_a = $togo * sin( $angle_a ); //this is our new longitude offset
printf( "maps.google.com/maps?z=17&q=loc:%f+%f\n",
$verts[ $lines[$i]['verta'] ]['lat'] + ( $side_b * $latoper ),
$verts[ $lines[$i]['verta'] ]['lng'] + ( $side_a * $longoper )
);
}
Yes, I used straight trig, not spheroid geometry - we're talking about distances of hundreds of feet, here, so I decided that the curvature of the earth wasn't relevant. In my test cases, I was generally within 100 feet of the actual location, and this is mostly due to the inaccuracies within the TIGER/Line data. For example, a tlid might have a start address of 8500 and an end address of 8799, but the first house number is actually 8601. This particular error might geocode the house a football field away from where it really sits.
The rough steps to geocode an address are these:
1) Get the appropriate TIGER/Line shapefile from the Census. You need to get the county All Lines file, as this is the one which has points with latitude and longitude.
2) Convert the shapefile for easier access (optional); rather than deal with learning a GIS system, such as GRASS, I opted to load the shapefile data into MySQL. I used PERL and the CPAN library called Shape to parse the shapefiles into flat files that I could load into MySQL. I went all relational and created two tables - the first is called shape_record, and is essentially unique to TIGER/Line ID (tlid). This table contains the ZIP Codes, street names, and address range information. The second table is shape_detail, is related to the shape_record on tlid. shape_detail contains each of the vertices of the TIGER/Line along with their latitude and longitude.
3) Fairly important step, here, is to standardize the data on each side of your operation. The field with the street name in it has some irregularities, and your input address may also need some cleaning up.
4) Enter the shape_record table looking for your street name and ZIP code. Narrow the result set to those tlids which have addresses which surround yours. Note that you may have more than one tlid for a single input address.
5) Enter the shape_detail table placing these records (generally at least two) into an array. These are the points of your street. Interpolate as appropriate - this part is easier expressed in code, so here's my hack-job in PHP:
$res = mysql_query( $sql, $conn );
if ( $res )
{
while ( $row = mysql_fetch_assoc( $res ) )
{
$verts[$row['vertid']] = array( 'lat' => $row['lat'], 'lng' => $row['lng'] );
}
mysql_free_result( $res );
// get the line segments;
//calc total line length;
$lines = array();
for ( $i = 1; $i < sizeof( $verts ); $i++ )
{
$lines[] = array(
'length' => sqrt(
( abs( $verts[$i]["lng"] - $verts[$i-1]["lng"] ) * abs( $verts[$i]["lng"] - $verts[$i-1]["lng"] ) )
+
( abs( $verts[$i]["lat"] - $verts[$i-1]["lat"] ) * abs( $verts[$i]["lat"] - $verts[$i-1]["lat"] ) )
),
'segments' => 0,
'verta' => $i - 1,
'vertb' => $i
);
}
$streetlen = 0;
for ( $i = 0; $i < sizeof( $lines ); $i++ )
{
$streetlen += $lines[$i]['length'];
}
// calculate the number of house-points ( tohn - fromhn )
$segments = abs( $_REQUEST['fromhn'] - $_REQUEST['tohn'] );
$seglen = $streetlen / $segments;
$togo = abs( $_REQUEST['fromhn'] - $_REQUEST['number'] );
for ( $i = 0; $i < sizeof( $lines ); $i++ )
{
$lines[$i]['segments'] = $lines[$i]['length'] / $seglen;
$togo -= $lines[$i]['segments'];
if ( $togo < 0 )
{
$togo += $lines[$i]['segments'];
$selected_line = $i;
break;
}
}
//now we have a two points, establishing a line, and a third value which represents a vector along the line from the first point
//calculate the point at the end of the vector.
$longdiff = abs( $verts[ $lines[$i]['verta'] ]['lng'] - $verts[ $lines[$i]['vertb'] ]['lng'] );
$latdiff = abs( $verts[ $lines[$i]['verta'] ]['lat'] - $verts[ $lines[$i]['vertb'] ]['lat'] );
if ( $verts[ $lines[$i]['verta'] ]['lng'] > $verts[ $lines[$i]['vertb'] ]['lng'] )
{
//going west
$longoper = -1;
}
else
{
//going east or nowhere
$longoper = 1;
}
if( $verts[ $lines[$i]['verta'] ]['lat'] > $verts[ $lines[$i]['vertb'] ]['lat'] )
{
//going south
$latoper = -1;
}
else
{
//going north or nowhere
$latoper = 1;
}
if ( 0 == $longdiff * $latdiff )
$angle_a = 0;
else
$angle_a = atan( $longdiff / $latdiff );
$angle_b = M_PI - ( ( .5*M_PI ) + $angle_a );
$angle_c = .5 * M_PI;
$togo *= $seglen; //this is the hypotenuse
$side_b = $togo * sin( $angle_b ); //this is our new latitude offset
$side_a = $togo * sin( $angle_a ); //this is our new longitude offset
printf( "maps.google.com/maps?z=17&q=loc:%f+%f\n",
$verts[ $lines[$i]['verta'] ]['lat'] + ( $side_b * $latoper ),
$verts[ $lines[$i]['verta'] ]['lng'] + ( $side_a * $longoper )
);
}
Yes, I used straight trig, not spheroid geometry - we're talking about distances of hundreds of feet, here, so I decided that the curvature of the earth wasn't relevant. In my test cases, I was generally within 100 feet of the actual location, and this is mostly due to the inaccuracies within the TIGER/Line data. For example, a tlid might have a start address of 8500 and an end address of 8799, but the first house number is actually 8601. This particular error might geocode the house a football field away from where it really sits.
Friday, November 5, 2010
C++ magic (or, How to make a bug)
I was reading through some old code of mine, something I had written 10 years ago, and came across what I thought must either be a bug I had missed or pure magic. The essence of what I was looking at can be summarized as:
When I read it, my gut said that push_front should barf because I'm passing a type that is not the same as the list is expecting.
This isn't actually magic, and in fact this sort of loose programming could easily lead to bugs. The list template is calling a constructor to make it's own locally-scoped string object, and my input just happens to line up to one of the overloaded constructors for std::string class. Observe similar behavior from the following sample program:
In both cases, I'm passing a quietly convertible value into the push_front() method. While the first code would result in correct behavior, the second might easily present a bug. The lesson to be learned, here, is that while compiler warnings are useful, they don't prevent logic bugs.
std::list< std::string > mylist;
std::string * myfunc( const char *t )
{
mylist.push_front( t );
std::list< std::string >::iterator i;
i = mylist.begin();
return( &(*i) );
}
When I read it, my gut said that push_front should barf because I'm passing a type that is not the same as the list is expecting.
This isn't actually magic, and in fact this sort of loose programming could easily lead to bugs. The list template is calling a constructor to make it's own locally-scoped string object, and my input just happens to line up to one of the overloaded constructors for std::string class. Observe similar behavior from the following sample program:
std::list< int > mylist
void buggy_code(){
mylist.push_front( 12.456F );
std::list< int >::iterator i;
i = mylist.begin(); std::cout << ( *i ) << std::endl;
}
In both cases, I'm passing a quietly convertible value into the push_front() method. While the first code would result in correct behavior, the second might easily present a bug. The lesson to be learned, here, is that while compiler warnings are useful, they don't prevent logic bugs.
Blender procedural texturing (texture nodes) - Stained Glass
OK, I'm jumping back into Blender after an extended hiatus. First steps, play with new stuff.
This morning, I decided to try and create a stained glass texture.
Here's the node setup:
As you can see, the color output is mapped to color and specularity; the bump output is mapped to inverse normals.
Here's the test render:
I know it needs some work, but this could be a really nice effect.
This morning, I decided to try and create a stained glass texture.
Here's the node setup:
As you can see, the color output is mapped to color and specularity; the bump output is mapped to inverse normals.
Here's the test render:
I know it needs some work, but this could be a really nice effect.
Subscribe to:
Posts (Atom)

