There are good solutions for maintaining network hardware.

I, by choice, prefer working with software. When I deal with networks, it’s usually only so that I can solve some problem and then get back to working on my software projects. That being the case, I often find myself in the following situation:

  1. Installed latest network hardware
  2. Configured said hardware and our networks.
  3. Left network in operation
  4. Come back two years later when something needs changed.

The story always ends the same. All the equipment I put in has been succeeded by newer, cooler hardware. The stuff we now have is outdated and only available as a support solution.

There are solutions for maintaining a network over time. Multilink Communications Products for instance offers all kinds of old and new Cisco Equipment. You’ll have to check them out yourself to see if they suite your needs and if their prices is right, but for me, I found exactly the old firewall model and license that we use in our network VPNs. They have an easy to browse menu of products. It’s easy, for instance, to browse to the Cisco Switches and see every model they have available. Once you find what you need, you can request a price quote depending on if you want new, used/refurbished, or simply whatever costs the least. There is also a Hardware and equipment lease option if you like that better.

Posted in Hardware | Tagged , , | Comments Off on There are good solutions for maintaining network hardware.

Extending std::exception

So you’re writing some C++ code, feeling all object oriented and all, and you decide you’d like an application specific exception whenever one of your methods has an issue. You’d like to have error messages that the exception can print up if thrown and you think to yourself, “hey, I’ll just extend std::exception, add the error string, and be on my way.”

Problem: So here is the puzzle. What is wrong with this code:

#include 
#include 
using namespace std;
class my_error : public exception {
  private:
   string m_err;
  public:
    my_error ( const string &err) : m_err(err) {}
    const char* what() { return m_err.c_str(); }
};

Think about it for a bit before scrolling down more. Take a look at the header definition for exception.

Ok, ready to move on? Did you find the problem?

Answer:

The standard exception does not declare it’s copy constructor virtual.

 exception& operator= (const exception&) throw();

This is in part because in order to provide exception safe c++, the exception class can’t throw exceptions itself. This is the same reason using strings member variables is discouraged for exceptions. Their constructors can also throw exceptions. Anyway, the result is that if client code catches std::exception, copies the exception, and prints it, m_str hasn’t been copied and you get garbage or errors. Not what was expected was it.

Solution

This whole problem was loaded just slightly. There is already a standard exception that can take a string message as an argument.

#include 
class my_exc : public runtime_error {
 public:
  my_exc ( const string &err ) : runtime_error (err ) {}
  // there, you can add more methods here.
  // remember, you can't add data members any more here
  // than you can add them to exception derived classes though.
};

Get it? Got it? Good.

Posted in Programming | Tagged , , , | 2 Comments

Adding more disk space with LVM2

I’ve always known that virtualizing things can make management of all types of resources easier. Recently, I had the most pleasant experience adding disk space to a virtual machine. Of course, if you use LVM, this can happen just as easily with real physical disks, but for me, I was able to do this without restarting my machine.

Issue: I’m out of disk space on my root partition.
Solution: The root partition is created on a logical volume with LVM2. Just add another disk, extend the volume group, and then extend the logical volume.

# Added new physical partition /dev/sda3
# create a physical volume out of it
> pvcreate /dev/sda3
# Now, add it to the volume group that my logical volume is on
> vgextend VolGroup00 /dev/sda3
# Now that the volume group has more disk space, the logical volume can grow
> lvextend -L+11G /dev/VolGroup00/LogVol00
# Ok, last of all, I want to filesystem to recognize that more space is available
> fsadm resize /dev/VolGroup00/LogVol00
# sweet, I have more space now
> df -h

All that was done without having to take the system off line. Linux makes life easy sometimes doesn’t it!

Posted in System Administration | Tagged , , | 1 Comment

FX2 CyStream throughput test with SDCC and fx2lib

I’ve been optimizing my firmware for throughput and I thought a good benchmark would be to test it against the CyStream example provided by Cypress. I modified their CyStream.c file to be compatible with the latest firmware file provided by fx2lib.

Here is a summary of the changes needed:

  • Include the appropriate header files
  • Change the functions for vendor commands to match the fx2lib functions.
  • Change the interrupt handlers
  • Probably the most work of the whole process, rewrite the dscr.a51 file to be in asx8051 format.

Anyhow, The attached zip files contains the sources for the modified CyStream. Here are some of my benchmark results:

Firmware/Test Speed
CyStream Application on Windows with Keil firmware ~41 MBps
Keil firmware, Linux Host with included speed.py ~40 MBps
SDCC firmware, unchanged, speed.py ~35.6 MBps
SDCC firmware, optimization 1, speed.py ~40.9 MBps
SDCC firmware, optimization 2, speed.py ~41.9 MBps
SDCC firmware, optimization 3, speed,py ~42.9 MBps
SDCC firmware, optimization 3, CyStream App on Windows ~43.8

  1. Optimization: remove two if checks for interrupts in main loop and handle them directly in the interrupts
  2. Optimization: remove another if in main loop.
  3. Optimization: completely remove everything in main loop, commit packets directly in main loop, don’t write to ep buffer before committing data. Note that the fastest I could get this to go was 42.9 (or 43.8 on Windows). Further removing things didn’t make it go any faster so I think I hit my Host PC limits.

You’ll need to download fetch the latest fx2lib from github and then modify the Makefile to compile the attached firmware. You’ll need to install the fx2load package for Python from fx2lib in order to run the speed test.

CyStream for SDCC and fx2lib

Enjoy. I hope fx2lib helps someone out. Check out my other posts on fx2lib to find our mailing list and more SDCC examples for the Cypress FX2.

Posted in Hardware, Programming | Tagged , , , , , , , | 12 Comments

GnuCash Budget Followup

Here is a followup to a few questions that have come up since my GnuCash Budget post.

  1. How much did I spend for this month?

    I find the Cash Flow report useful for this question. (Reports->Income & Expense->Cash Flow). You need to customize the report a bit before you get the information you need though. 1st, change the date range to the period of time you’re interested in. 2nd, select any additional accounts you want included. By default, the report only includes expenses and asset (cash) accounts. You need to select any liability accounts (like credit cards) that you spend money from.

    When you’ve set up the report, you get Money In and Money Out sections. The Money Out shows you not only how much each budget account spent, but also you can see which expense accounts you spent the money in.

    This is a particular subtlety of this budget system that I really like. You don’t have to spend budget money from the same account as the expense. Example: I have my own personal budget but I use it to by items in many different expense accounts, e.g., movies, games, food, computers, etc. The report might look like this:
    Budget: My budget: 100
    Expense: Food 25
    Expense: Movies 25
    Expense: Computer 50

    I do that exact thing all the time. We might buy a particular expense item but choose to take it out of our savings budget for instance.

  2. Did I go over the budget this month?

    This one is easy. There is not “this month” or “last month” in this budget system. You can choose to think of your budget that way, but I like to think of it as a continuous budget amount. Budgets increase when you increase them and decrease when you spend from them. For me, my budget increases when I earn income. That might be monthly, bi-weekly, and it may have occasional spikes. (Like we got our tax refund back, so I added the money from that to our budgets).

  3. How much did I spend on food and transportation this month?

    Just look at the Cash Flow report and find the category you’re interested in. Note that you can look at both the Expense (how much you spend on a certain thing.) and the Budget (how much you used from the budget.) They may be the same or they may be different depending on how you choose to record transactions.

  4. How much was my net-income for the last quarter?

    Since the budget balances to 0, it doesn’t affect your balance sheet. You can use the standard GnuCash balance sheet and asset reporting to figure out your income etc. One note though, I try to remember that my budget money will need to be spent at some point in the future.

  5. Which area can I spend less and save more?

    This one is pretty easy. Just look at your budget accounts in the main GnuCash window. Since you always see the current balance of your budget account, just look at which ones are positive and which ones are approaching zero (or heaven forbid you didn’t go negative did you?).

    We transfer money between budgets too. Say I built up over a few months a few hundred extra dollars in my Auto:Fuel budget since gas prices have been low. I can decide to make a transfer from that budget to another one that perhaps we had some extra expense from.

Since writing my original post, I’ve only grown to like this system more and more. Feel free to post more questions/comments and I’ll do my best to answer.

Posted in Miscellaneous | Tagged , , , | 14 Comments

Finding the Best Mobile Broadband Service



Mobile broadband is an exciting, fairly new service that provides wireless Internet access virtually anywhere you can get a mobile phone signal. The service usually requires some sort of data stick or card and is a very reasonably priced service that is much easier than trying to find hot spots, Wi-Fi or an un-secure wireless network to tap into.



So how do you find the best mobile broadband service? First, decide what features you are looking for. Are you going to need lots of download space for songs and videos? If this is the case look for a package that gives you a large or better, unlimited download limit. If you just plan on using it for email and chatting you can go with a lower limit.



Most of us won’t settle for anything less than super fast Internet so again, consider what you’ll be using yours for. If it’s just email and chat you can get an average speed but if you’re a high load user you can go for a higher speed.



And of course always consider price. Compare broadband plans and see how they stack up. And don’t be afraid to tell one service provider you found a better deal somewhere else (even if the package you want is with them)! 



Finally, always double check if there are any hidden costs like charges for the USB key or card, setting up the service and charges if you exceed your download limit as well as contracts you may have to sign.

Posted in Web | Tagged , | 1 Comment