[weewx-user] Re: How to create a custom CSV file?

2018-10-17 Thread rmc7mm


On Wednesday, October 17, 2018 at 8:40:55 AM UTC-4, Herwig Diessner wrote:
>
> Hello all,
>
> I need to export only 3 pieces of data from weewx into a file.
> The file should contain a single line of text in the following format:
> date;pressure;temperature
>
> The date is in the format "-MM-dd HH:mm:ss".
> The pressure and temperature are expressed in hPa and °C, respectively
>
> I tried to use the CSV extension and succeeded in
> - single line
> - time-format
>
> However, all sensor data is exported and the delimiter is fixed to , 
> instead of the required ;
>
> Is there any chance to succeed using the CSV extension (e.g. options to 
> define the delimiter as ; instead of , - and options which sensor data is 
> to be exported)?
> Or do I need another extension, or is there even another way?
>
> My searches on "export" and "csv" didn't bring any clues.
>
> In case of interest, this is my use case:
> I want to use temperature and pressure data to calculate "refraction" data 
> for astrophotography using a 10micron telescope mount.
> This mount allows to calculate refraction data automatically if fed with a 
> text file with the specifications above.
> Probably there are more users who might make use of this.
>
> Thank you for any hint,
>
> Herwig
>


The following mysql select statement gave me the results you wanted.  
2016-02-21 19:10:24;29.92;52.34
My database isn't metric but you can convert if necessary.  If you use 
sqllite i'm sure someone will convert for you.

select timestampadd(second, dateTime, '1970-01-01'),barometer,outTemp into 
outfile 'test.csv' fields terminated by ';' from archive limit 5;

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] Re: weewx crashes with error: unpack requires a string of len 104

2018-04-02 Thread rmc7mm


On Monday, April 2, 2018 at 11:21:05 AM UTC-4, Graham Seward wrote:
>
> Thanks Bob
> I look forward to seeing it - like you though I'm not a programmer and not 
> sure I'll be able to hack the driver myself - still I'll have a go!
> As you say, hopefully Susan will see this.
> Many thanks
> Graham
>

Graham,
Here is a copy of the driver I'm using.  There are only 3 sections I 
modified starting about line 261, 314, and 346.
I hope it works for you

Bob

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#
#Copyright (c) 2017 Susan Mackay
#   acknowledging that this driver code originated from and 
#   is structured in a similar way to the Weewx 'Simulator' driver code
#   that carries the following line:
#Copyright (c) 2009-2015 Tom Keffer 
#
#
"""hp1000 driver for the weewx weather system"""

import math
import time
import datetime

import weedb
import weewx.drivers
import weeutil.weeutil
from weewx.units import convertStd

import syslog
import sys
import socket
import struct

DRIVER_NAME = 'HP1000'
DRIVER_VERSION = "1.0"

UDP_BROADCAST_PORT = 6000
TCP_PORT = 6500


def loader(config_dict, engine):
station = HP1000Driver(**config_dict[DRIVER_NAME])
return station


def logmsg(level, msg):
syslog.syslog(level, 'HP1000: %s' % (msg))


def logdbg(msg):
logmsg(syslog.LOG_DEBUG, msg)


def loginf(msg):
logmsg(syslog.LOG_ERR, msg)


def logerr(msg):
logmsg(syslog.LOG_ERR, msg)


class HP1000Driver(weewx.drivers.AbstractDevice):
"""HP1000 Driver"""

def __init__(self, **stn_dict):
"""Initialize the HP1000 driver"""
self.ws_name = "HP1000"

loginf('HP1000 Starting')

self.internal_test_mode = False

# Save the configuration parameters
try:
self.ip_address_mask = stn_dict['ip_address_mask']
except KeyError, e:
raise Exception(
"Required parameter 'ip_address_mask' has not been specified")
self.retry_count = int(stn_dict.get('retry_count', 5))
self.socket_timeout = float(stn_dict.get('socket_timeout', 5))
self.loop_delay = float( stn_dict.get('loop_delay', None))
self.retry_wait = int(stn_dict.get('retry_wait', 5))
self.max_retry = int(stn_dict.get('max_retry', 5))

self.last_rain_value = None
self.last_rain_time = None

loginf('Address Mask = %s' % self.ip_address_mask)
loginf('Retry count = %f' % self.retry_count)
loginf('Socket timeout = %f' % self.socket_timeout)
if self.loop_delay is None:
loginf('No loop delay')
else:
loginf('Loop delay = %f' % self.loop_delay)
loginf('Retry Wait = %f' % self.retry_wait)
loginf('Max Retry = %f' % self.max_retry)

# Show that we are not connected to a weather station
self.ws_socket = None

def string_to_null_padded(self, source, max_length, padd_char='\0'):
# Create a byte array
passed_string = source.ljust(max_length, '\0')
return passed_string

def create_cmd_string(self, cmd="READ", argument="NOWRECORD"):
# Create the complete packet
cmd_packet = '{0:<8s}{1:<8s}{2:<12s}'.format(
self.string_to_null_padded('PC2000', 8),
self.string_to_null_padded(cmd, 8),
self.string_to_null_padded(argument, 12))
cmd_packet = self.string_to_null_padded(cmd_packet, 40)

return cmd_packet

def convert_units(self, source, target):
"""Suppress errors when the conversion cannot occcur
such as when the source and target unit are the same - it happens a lot
in this code"""
try:
result = convertStd(source, target)
except:
result = source
return result

def genLoopPackets(self):
network_retry_count = self.max_retry   # Local network failure retry counter
while True:
if self.ws_socket is None:
# Search for a weather station on the specified

if not self.internal_test_mode:
# Broadcast for a weather station
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,
 socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.settimeout(self.socket_timeout)
bcData = "PC2000\0\0SEARCH\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
retry_counter = self.retry_count
sender_addr = None
while True:
#

[weewx-user] Re: weewx crashes with error: unpack requires a string of len 104

2018-04-02 Thread rmc7mm


On Monday, April 2, 2018 at 9:48:57 AM UTC-4, Graham Seward wrote:
>
> Hi
> Did you ever get a solution to this issue. I have weewx running with 
> Susan's HP1000 driver connecting to a Maplin N23-dq (HP1000 clone). Took me 
> a while to get it going in first place but eventually a firmware upgrade on 
> the HP1000 resulted in success. However after a couple of hours of running 
> weewx stops. Syslog throws up the same error as yours:
>
> Mar 31 17:04:38 raspberrypi weewx[1148]: engine: Main loop exiting. 
> Shutting engine down.
> Mar 31 17:04:38 raspberrypi weewx[1148]: engine: Shutting down StdReport 
> thread
> Mar 31 17:04:38 raspberrypi weewx[1148]: engine: StdReport thread has been 
> terminated
> Mar 31 17:04:38 raspberrypi weewx[1148]: engine: Caught unrecoverable 
> exception in engine:
> Mar 31 17:04:38 raspberrypi weewx[1148]:   unpack requires a 
> string argument of length 104
> Mar 31 17:04:38 raspberrypi weewx[1148]:   Traceback (most recent 
> call last):
> Mar 31 17:04:38 raspberrypi weewx[1148]: File 
> "/home/weewx/bin/weewx/engine.py", line 871, in main
> Mar 31 17:04:38 raspberrypi weewx[1148]:   engine.run()
> Mar 31 17:04:38 raspberrypi weewx[1148]: File 
> "/home/weewx/bin/weewx/engine.py", line 187, in run
> Mar 31 17:04:38 raspberrypi weewx[1148]:   for packet in 
> self.console.genLoopPackets():
> Mar 31 17:04:38 raspberrypi weewx[1148]: File 
> "/home/weewx/bin/user/HP1000.py", line 524, in genLoopPackets
> Mar 31 17:04:38 raspberrypi weewx[1148]:   interp_data = 
> struct.unpack("8s8s16s8shbb14fbbh", rxData)
> Mar 31 17:04:38 raspberrypi weewx[1148]:   error: unpack requires 
> a string argument of length 104
> Mar 31 17:04:38 raspberrypi weewx[1148]:   Exiting.
>
> Weewex v3.8 on Raspberry Pi model B 
> Short of shutting down and restarting I have not been able to resolve the 
> issue
>
> I've searched all the threads and can't find a solution - is there one?
> Any help apprecia
>
 
 Hi Graham,
Yes I did get a fix for the problem.  Thats the short answer.  The long 
answer is I hacked the driver and if I remember Weewx it self.  I'll post 
what I did, but I want you to know that I'm a (almost) 80 yr old truck 
driver not a programmer.
Maybe Susan will see this and chime in.  

Luck
Bob

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] Re: weewx crashes with error: unpack requires a string of len 104

2017-04-15 Thread rmc7mm
Your right Andrew, I didn't give much information. The farther I get into 
my dottage the more I forget other people can't read my mind.

I have a Ambient ws1001, Firmware is ver 2.6.1,  weewx 3.7.1, with Susans 
HP1001 driver.

root@raspberrypi:/home/pi# systemctl status weewx
● weewx.service - LSB: weewx weather system
   Loaded: loaded (/etc/init.d/weewx)
   Active: active (exited) since Sat 2017-04-15 14:24:30 EDT; 19min ago
  Process: 6163 ExecStop=/etc/init.d/weewx stop (code=exited, 
status=0/SUCCESS)
  Process: 6177 ExecStart=/etc/init.d/weewx start (code=exited, 
status=0/SUCCESS)

Apr 15 14:28:38 raspberrypi weewx[6204]:   unpack requires a string 
argument of length 104
Apr 15 14:28:38 raspberrypi weewx[6204]:   Traceback (most recent call 
last):
Apr 15 14:28:38 raspberrypi weewx[6204]: File 
"/usr/share/weewx/weewx/engine.py", line 871, in main
Apr 15 14:28:38 raspberrypi weewx[6204]:   engine.run()
Apr 15 14:28:38 raspberrypi weewx[6204]: File 
"/usr/share/weewx/weewx/engine.py", line 187, in run
Apr 15 14:28:38 raspberrypi weewx[6204]:   for packet in 
self.console.genLoopPackets():
Apr 15 14:28:38 raspberrypi weewx[6204]: File 
"/usr/share/weewx/weewx/drivers/HP1000.py", line 327, in genLoopPackets
Apr 15 14:28:38 raspberrypi weewx[6204]:   interp_data = 
struct.unpack("8s8s12s12shbbffbbh", rxData)
Apr 15 14:28:38 raspberrypi weewx[6204]:   error: unpack requires a 
string argument of length 104
Apr 15 14:28:38 raspberrypi weewx[6204]:   Exiting.

I hope this helps.

On Saturday, April 15, 2017 at 1:26:08 PM UTC-4, rmc...@gmail.com wrote:
>
> Subject says it all.
>
> I know this was brought up before but I can't find the thread.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] weewx crashes with error: unpack requires a string of len 104

2017-04-15 Thread rmc7mm
Subject says it all.

I know this was brought up before but I can't find the thread.

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.