19. November 2005 17:53
Hey looks like the new .Net 2.0 supports a serial class that makes serial communications a snap.
I need to get going on some project to try this out. Maybe a PC to BX24 project that will be useful in my house. I need to give it some thought.
17. November 2005 21:50
Well I have been looking at VS.Net 2005 some since it has released. I wanted to try out some of the new features. Well I am pretty attached to using NUnit so once I got a little bit of code going in VS.Net 2005 I decided it was time to try NUnit. Fortunately there is a new iteration release of NUnit (2.2.3) that works with VS.Net 2005.
So I downloaded it and wrote my first test like I always do. Create a test project, add a reference to NUnit, add a new class, put a TestFixture attribute on the class, and add a public method that returns void that also has the Test attribute. I then proceeded to fire up NUnit GUI and run the test. However the test I wrote does not show up in the GUI. I fiddled around with the test code for a while and I even downloade the NUnit source code to try and figure out why my test was not seen by NUnit. Well after about 30 minutes of messing around I realized that when you add a new class to VS.Net 2005 project it looks like the following
I never noticed the fact that public
does not appear before the keyword class
. So the test class could not be seen by NUnit.
14. November 2005 11:54
I have wanted to do this with my kids for some time. I have seen several kits that are expensive that I just don't care to purchase. Well now I have no excuse http://homepage.ntlworld.com/telescope/Rocketweb/index.htm
20. October 2005 01:25
A previous post I explained how simple it is to test your code even though you might not have a fancy test framework like NUnit. In this post I am going to give another example of what I did to tackle a robot navigation problem and fully testing it without actually running the code in a real robot. My point here is that it is a good practice to write test code to test sub modules to simulate all possible scenarios that would be tough to do in the real robot.
So here is the problem:
I have a compass module that outputs a heading value that equates to 0-359 degrees. I needed a module that when given a target heading and a current heading it could return the differance between the two in degrees. The return heading difference would range from -180 to 180 degrees. This return value could be processed further to determine which direction the robot needed to turn to reach the target heading. A negative heading ment to turn left and a positive number would mean turn right.
So my approach was to first identify a list of target and current headings and what I would expect the return value would be for these input parameters. I did this for 17 different scenarios. I placed the values in a spread sheet and analyzed the pattern that emerged. I took this pattern and coded a simple class (module) that would impliment the pattern.
Here is the method of the class:
Public Function GetHeadingDifference(currentHeading as Integer) As Integer
' Returns the following
' -180 to + 180
' Negative number means the robot would have to turn to the left to get closer
' to the targetHeading
' Uses module variable targetHeading
Dim targetMinusCurrent as Integer
targetMinusCurrent = targetHeading - currentHeading
If (targetMinusCurrent<181) And (targetMinusCurrent>-181) Then
If (targetMinusCurrent<-180) Then
GetHeadingDifference=360 - ABS(targetMinusCurrent)
GetHeadingDifference=(360-ABS(targetMinusCurrent)) * (-1)
I then created another test class (module) that would call the navigation module and pass in the 17 scenarios and validate the return heading.
Public Sub Main()
'.......... Test code ..........
'This needs to be done only once per program, or when you want to change the baud
Call UARTsetup(3, 19200)
Dim testResult as Integer
Dim newHeading as Integer
Dim targetHeading as Integer
Dim currentHeading as Integer
DebugPrintLine "TestHeading Tests"
If (testResult<>0) Then
DebugPrintLine "Test 1 Failed"
DebugPrintLine "Test 1 Passed"
If (testResult<>-1) Then
DebugPrintLine "Test 2 Failed"
DebugPrintLine "Test 2 Passed"
........... more test code omitted for clarity
I used the 17 scenaros that I layed out on the spread sheet to prove out my logic. Since the module is fully tested based on these scenarios I have complete confidence that the module will work when it is included in the main robot code project.
8. July 2005 23:15
Well I have wanted to get an external drive to solve one primary problem I have. Desktop and Laptop synchronization. First Some Background
I am a permanent virtual employee for a company in Scottsdale Arizona. I use the company desktop PC in my home office. I routinely travel to Scottsdale which forces me to take along a laptop. The main problem I have is getting my files off the desktop and onto the laptop for the trip. Then when I return from the trip I like to move the files from the laptop onto the desktop. Well to transfer a large amount of files over ethernet from desktop to laptop and back can be a very slow process while VPNed in. The transfer goes through Scottsdale. I can't even use local IP addresses to route the traffic. Currently I only had one option. Disconnect from VPN and transfer the files. This basically keeps me from working at all while the copy is happening. So I needed another solution. Enter the solution
Since I had a Comp USA gift card of a sizeable amount I decided to start at my local store looking for an external drive solution. I had an old 5 1/4 30 gig hard drive that I intended to just get an external USB case for. The drive came out of an old computer and I wasn't even sure if it was fully functional. Looking at external cases they where around $40. Seemed like a large amount of changed to drop on just a case. So I started to look for another solution. I stumbled across the Hammer Storage 80 gig USB 2.0 device that was on sale (with rebate) for $69. Most other external drive solutions started at $99 so this seemed in my price range. So I grabbed one of these drives and took it home. Conclusion
I am very happy with the device. You don't even have to load any drivers for it! It just works! I made some simple batch files to copy the data from my desktop to the external drive. And it worked relatively fast. The best thing is that I can continue to work as it is copying files. Now getting my laptop ready for a trip is no longer a painful process.
30. June 2005 20:26
Noticed another little problem with my copy podcast program
. I need to do some clean up on the directories of the destination (SD card). After I delete podcasts on my pocket PC many empty folders start to accumulate. So I need to add a process to clean up empty folders on the destination folder.
So far I have been using this program for almost 2 weeks. I like this setup a lot better than just relying on Doppler and Microsoft Media Player to manage the synchronization process. All I need to do is make the copy program a little more friendly and add a few abilities to the Media Player to support bookmarks and auto delete.
22. June 2005 14:45
In my program that copies podcasts over to my SD card
I noticed a few things that need to be changed.
The way I am using this the copy process is really a move. I am moving the file to the SD card from it's original place on the local PC hard drive. This means the file should retain it's original date. I do not think it is doing that in my program.
Files should be moved in chronological order. This helps to ensure the oldest files get copied first in the event there is not enough room on the destination.
21. June 2005 00:35
This is a follow up on my post about Listening to Podcasts
. I went ahead and developed a small application that grabs the podcast files and moves them to the removable media card. Here is a little idea on what it does.
- Tests to be sure the destination folder (removable media card) is available
- Looks for files of type MP3 in the source folder walking all the directories
- If a file is found verifies that enough room is on the destination folder
- Copies the file to the destination
- Removes the file from the source
- When all files are processed it looks for empty directories in the source directory and deletes them
All I have to do when I am done with listening to the podcast on my Dell is delete it. The only problem I have left is that the Windows Media Player does not support bookmarks.
Room for improvement:
Currently the application must be launched manually and pass into it the source and destination directories. It would be nice to have a service that just watches the source folder for new files and process them as they come in. The program looks for mp3 files only. It would be nice to add support for other media files.
19. May 2005 06:53
I have been doing a lot of Unit Testing in my day job using NUnit as the framework. I find writing code to test code is very interesting and makes my coding efforts less bug prone. However in my off time I often mess around with non .Net programming projects and I miss the ability to write test code in these projects. Well it is not too hard to follow the same sort of unit testing practices when you do not have a testing framework in place.
Just recently I was writing some BX24 code for a robotic project. I needed to create some conversion procedures to go from a Byte/Integer to a String and a String to a Byte/Integer. How would I determine that my new procedures would work as designed? Certainly I could not rely on the production robot code to test the conversion procedure.
The BX24 programming language has the concept of projects and source modules. A project is nothing more than a collection of source modules. One of the source modules must be the main entry point of the project for starting execution. This concept allows me to simply create test projects that are designed to test a single source module.
So I moved my conversion procedures into a Conversion Module and made a Conversion Test project. Then I proceeded to write test code in the main module of the Conversion Test project to exercise the Conversion Module. I now had unit tests that exercised the outer bounds of the Conversion Module. I proceeded to fix bugs in the Conversion Module until all tests passed.
Of course without a framework I did not have the nice GUI with Red/Green lights to tell me a test passed or failed but it sure did help me determine if my module was fully functional or not. So if you have a programming project that does not have a nice unit testing harness but your IDE supports module level programming you to can use the above techniques to write bug free code.