2023-12-23

On NS*DateFormatters

There now exists NSDateFormatter and NSISO8601DateFormatter and their behaviour when a timezone is not set is not the same: NSDateFormatter produces strings formatted for local time while NSISO8601DateFormatter produces string formatted for UTC.

As an example, given a date-time of 2000-12-31T23:00:00Z

NSDateFormatter with no timezone set and full styles:
Monday, January 1, 2001 at 10:00:00 AM Australian Eastern Daylight Time
NSISO8601DateFormatter with no timezone set:
2000-12-31T23:00:00Z

Note that NSDateFormatter "applies" my local timezone automatically whereas NSISO8601DateFormatter doesn't. Sidebar: it seems that while NSDate carries no timezone information, it is always interpreted as UTC time.

2023-10-16

DIY EQMod Direct USB Cable

I am in the process of resurrecting my Eq5 Pro so it is compatible with ASIAir Mini. The first step is to build an EQMod Direct USB cable. While it is possible to buy one pre-made, since I had all the parts I decided to build it myself.

Based on the reference document I need to make an single-ended RJ45 cable. I followed T-568A colour scheme:

Based on this colour scheme, the connection to a USB-UART adapter is as follows:

RJ45ColourUSB-UART
4BlueGround
5Blue-WhiteRXI
6OrangeTXO

Plug the RJ45 end of the cable into the hand-controller port on the control box and the other end into the ASIAir Mini. Then power up the ASIAir Mini as usual and use one of the 12V outputs to power the SynScan. Make sure to switch on the SynScan as it has its own power switch. After this select EQMod for the mount model and leave the baudrate at the default value of 9600. Tap the enable-toggle-switch and the ASIAir Mini will attempt to connect to the mount. After a successful connection you should be able to manually slew the mount in RA and DEC in Preview mode.

Update: I have to power up the SynScan after the ASIAir has fully booted (made it's beeping noises) in order for them to communicate successfully. If both are powered up at the same time, something goes awry and the ASIAir Mini will not be able to connect.

2023-09-18

Build Log: SCD41 CO2 Sensor

CO2 concentration is a proxy for how well a space, especially an enclosed one, is ventillated. To this end I build a quick-n-dirty CO2 sensor using a SCD41 breakout board from pimoroni and bits and pieces I had in the workshop.

Took the opportunity to practice making enclosures, especially for an irregularly shaped circuit. The enclosure was designed in FreeCAD by taking a picture of the circuit then importing it as a reference image. After correct for scale the designed enclosure was reasonable accurate, needing only some small tweaks to dimensions to correct forperspective distortion. The result was then 3D printed on my FF Creator Pro.

The enclosure provides openings for a button (currently unused), a "cage" for the CO2 sensor, display and micro-USB port.

In addition to practicing painting techniques, I also wanted to try new ways of "labelling" my projects. Water-slide decals are widely used in model kits, and it turns out you can buy blank sheets with which to make your own decals with! I picked a cheap'ish option off Amazon. Just search for "water slide decal clear laser". Once they arrived it was a simple matter of designing the decals in inkscape, printing it out and cutting them to size. To complete the build, a plastic primer was applied, followed by colour coats, then a clear coat was applied, followed by the decal, followed by 2 more layers of clear coat.

Overall quite happy with the outcome! Could have done more sanding before applying paint to hide the layer lines better and the a matte coat I think would have worked better. Nonetheless the decal idea worked out well and I think it will be my goto - a big improvement over permanent markers.

2023-03-29

Unexpected Latency in Tinyproxy

I love tinyproxy, it is simple to setup and more than enough for my needs. Recently however I noticed that some clients were experiencing unexpected long delays when doing something as simple as curl google.com. After some sleuthing, I tracked it down to the fact I had

LogLevel Info

in my config. When this is set tinyproxy produces log entries such as

CONNECT   Mar 28 08:46:41 [7023]: Connect (file descriptor 7): [unknown] [123.123.123.123]

the [unknown] is due to tinyproxy attempting and failing to resolve the connecting IP into a hostname. It is this attempt to map IP to hostname that is causing the latencies observed. To resolve this I added offending IP to /etc/hosts

123.123.123.123 some-host-name

with the above entry the latency went away and the log entries now look like

CONNECT   Mar 28 20:39:49 [6879]: Connect (file descriptor 7): some-host-name [123.123.123.123]

Conda and Slow Proxies

The default conda connect timeout is 9.15 seconds (no idea why this is, seems to have been the case from day one). If the proxy is slow, e.g. it is in another country or AWS region, this timeout can be triggered and conda will prematurely close the connection.

To diagnose this issue, attempt 

curl https://repo.anaconda.com/pkgs/main/linux-64/current_repodata.json

with proxies enabled. If that works then increase the connect timeout as follows

conda config --set remote_connect_timeout_secs 30

conda should now be able to update and install new packages etc.

2023-02-04

Installing python package arcgis in conda on Apple Silicon

 In order to install the arcgis package in conda, you have to specify the architecture osx-64 otherwise the package will not be found. This works because MacOS will capable of running x86_64 code on Apple Silicon processors - that is how efficient they are!

 

conda install -c esri/osx-64 arcgis 

In fact to make everything else work you need to add the channels with architecture specified exactly, e.g. conda-forge/osx-64, esri/osx-64 and defaults/osx-64. Otherwise packages will be installed with a mix of architectures and appears not to be able to find each other.