Multiple cm160

Hello - I get your great code and try to make it working for more than 1 device. I did it, so I'd like to share it with you. Unfortunately I don't use git hub from the beginning, so I can't show you the working code, because I broke something at very end, and now i raises segfault - but maybe you can find the little wrong piece.

How it works - I decided not to use one program for all devices, but one program for one device. So if you run the program without any args, it will looks for devices. If it finds only one - it goes further, if finds more - shows serials and exits. In that case you have to run it with -s arg example cm160 -s AA001234 - in that case program finds only one matching device and goes further.

You choose the weekend/week tariff, but it is rather useless because of many different kinds of tariff - so I decided to change the stat tables - I remove column kwh_week_total and kwh_weekend_total and add kwh_0_total,kwh_1_total etc, and I planned to sum columns to get week/weekend or many other tariffs 

Sorry for changing {} but It is to messy for me.


Now I'm stuck in update_stat_db - the program enters it, executes sqls, but then segfaults and no changes in database...I can't debug it... So maybe you have a little piece of time?