## page was renamed from MortensPages/TechBlog = Shorewall Hairpinning = ''Hairpinning'' is a method for getting internally originating from hosts in the lan addressing the external IP of the gateway to be routed through the gateway. Setting it up with Shorewall is described in the [[http://www.shorewall.net/FAQ.htm#faq2 | Shorewall FAQs]] or, if the Shorewall documentation is installed, in the [[file:///usr/share/doc/shorewall-doc/html/FAQ.htm#faq2 | Local Shorewall FAQs]] = Reading Heart Rate from the Zephyr HxM BT = The [[http://www.zephyranywhere.com/products/hxm-bluetooth-heart-rate-monitor/ | Zephyr HxM BT heart rate monitor | target=_blank]] may be easily integrated into the [[http://meestuff.blogspot.no/p/meetrainer.html | meeTrainer | target=_blank]] application. The [[ http://www.zephyranywhere.com/media/pdf/HxMBT-APIGuide-2010-JUL-22.pdf | API specification | target=_blank]] for the HxM specifies that it transmits one 60 byte packet every second, and that the heart rate is shipped in one byte with index 12 into this packet. ~-{{{#!highlight python # Externally pairing and setup of the SP must be done as root: # $ rfcomm connect rfcomm1 00:07:80:5A:35:42 1 import serial import struct import time pkg_struct = struct.Struct('60B') pkg_size = pkg_struct.size zhxm = serial.Serial('/dev/rfcomm1') hr_idx = 12 dist_idx = [50, 51] speed_idx = [52, 53] strides_idx = 54 def read_hr(): zhxm.read(zhxm.inWaiting()) d = pkg_struct.unpack(zhxm.read(pkg_size)) return d[hr_idx] # # Make a running plot for the past 60 seconds of HR measurements # import matplotlib.pyplot as plt import numpy as np hrs = read_hr() * np.ones(60,dtype=np.uint8) plt.ion() fig = plt.figure() fig.set ax = fig.add_subplot(111) ax.grid(True) ax.set_yticks(np.arange(40,220,5)) ax.set_ylim(40, 220) hr_line, = ax.plot(hrs, 'ro-') while True: hr = read_hr() hrs = np.roll(hrs,1) hrs[0] = hr hr_line.set_ydata(hrs) fig.canvas.draw() time.sleep(0.5) zhxm.close() }}}-~