Gerrit Niezen

Maker of open-source software and hardware.

Feature image

Today I managed to get my new MTP module for Node.js working in Electron. There are still a couple of rough edges to smooth over, but I can retrieve a file from the device and then load and read it using Node's fs module:

var list = mtp.getFileListing();
console.log('Files:', list);
mtp.getFile(_.maxBy(list, 'id').id, 'test.ibf');
fs.readFile('test.ibf', (err, data) => {
  return cb(err, data);
});

In this specific instance, there are a bunch of files on the device, and I want to retrieve the one with the highest id, so I use _.maxBy() from lodash. mtp.getFile() gets the file from the device and saves it locally. I then use fs.readFile to read the file from the local disk.

Since I'm using version 3 of N-API and it's only available on Node v10 and higher, I needed to use the latest Electron v3.0.0-beta.4, which has Node v10.2.0 inside. Electron v2 has Node v8 inside, but for v8 N-API is still experimental, and also only supports N-API v1 and v2. Hopefully a stable version of Electron v3 will be released soon, so that I can get this code into the Tidepool Uploader.

#nodemtp

Comment on this post

Feature image

A week ago I wrote about finding the exact design for a spindle in our staircase that I wanted to replace. Yesterday I found out that there are actually a number of spindles on our staircase that are mismatched. Over the years, as various spindles broke, they have been replaced with different designs. I could make out at least three different designs being used.

I'm still impressed that I managed to find the exact match to the spindle I'm replacing, maybe even more so now that I know others have given up and just used whatever looked vaguely similar. It's also interesting to note that we didn't even notice that they were mismatched until I started looking into it.

Although my attempt at installing skirting boards yesterday was a bit of a failure, I think I managed to do a reasonable job today at cutting the new spindle to the correct shape and size of the old one, and fitting it into place using glue and nails. Maybe I'll even replace the other mismatched ones one day, so that they all look the same again.

Comment on this post

Feature image

Follow-up: the mitre box I 3D printed yesterday was a total disaster. It looked great coming off the 3D printer, but was a little too flexible due to its height. This morning, I clamped the skirting board to the mitre box after measuring, started sawing and about thirty seconds later pieces started breaking off. Three things I learned:

  • Don't use PLA for things that will be subject to outside forces – it's a bit too brittle and can snap off and break easily.
  • Don't print things so that the grain of the print is in the same direction as the force that will be applied.
  • Print things a bit thicker than what you think they need to be. They may take a bit longer to print, but at least you'll have a more useful print at the end.

Comment on this post

Feature image

There is a bedroom wall in our new house that is missing some skirting boards. It seems reasonably simple enough to do-it-yourself, so I watched a 2-part series on YouTube explaining how to fit skirting boards. One tip they had in there was to use a mitre box to help make straight cuts at 45-degree angles in the wood.

Now, I've never used a mitre box before, so I went to my local B&Q to have a look at the options. Given that my skirting boards are more than 16 centimetres high, I don't think a suitable one exists – they are all too low. So I decided to check out Thingiverse to see if there is a parametric version that I can customize for my needs. Low and behold, there is!

It took me less than 5 minutes from downloading the file, editing the variables in OpenSCAD, rendering a new .STL file and generating g-code in Prusa Slic3r, to starting the print. The estimated print time was 12 hours, so it is quicker than ordering from Amazon, and definitely much cheaper than buying it somewhere. I should remember to post an update here if it works!

#Making

Comment on this post

Feature image

In Part 3 I described how I started wrapping libmtp in a Node.js module. Today I discovered napi-macros, which makes writing N-API modules much easier. Recall the getFile function we had from last time:

napi_value getFile(napi_env env, napi_callback_info info) {
    napi_status status;

    size_t argc = 2;
    napi_value argv[2];
    status = napi_get_cb_info(env, info, &argc;, argv, NULL, NULL);
    if (status != napi_ok) {
        napi_throw_error(env, NULL, "Failed to parse arguments");
    }

    int id = 0;
    char path[20];
    napi_get_value_int32(env, argv[0], &id;);
    napi_get_value_string_utf8(env, argv[1], path, 20, NULL);

    int ret = LIBMTP_Get_File_To_File(device, id, path, NULL, NULL);

    napi_value retVal;
    status = napi_create_int32(env, ret, &retVal;);
    if (status != napi_ok) {
        napi_throw_error(env, NULL, "Unable to create return value");
    }

    return retVal;
}

I remember when I was writing that it felt very verbose. Now, using napi-macros this collapses into:

NAPI_METHOD(getFile) {
  NAPI_ARGV(2)
  NAPI_ARGV_INT32(id, 0)
  NAPI_ARGV_UTF8_MALLOC(path, 1)

  int ret = LIBMTP_Get_File_To_File(device, id, path, NULL, NULL);

  NAPI_RETURN_INT32(ret)
}

Wow, that's quite the difference – succinct and easier to read. I like it!

#nodemtp

Comment on this post

Feature image

A quick round-up of three of my favourite makers on YouTube at the moment.

Colin Furze

Colin is arguably one of the most famous makers on YouTube, with over 6 million subscribers. He builds insanely cool (and dangerous) things. Here is Colin building a jet-powered scooter for his son:

Estefannie Explains it All

I've written about Estefannie before. She has some great electronics builds on her channel, and is not afraid to share her mistakes. Watch her awesome three-part series on building a Daft Punk helmet for Maker Faire here:

Wintergatan

Wintergatan is a Swedish instrumental band. Band member Martin Molin documents the entire process of building the second version of their famous marble machine in his weekly videos:

#Making

Comment on this post

Feature image

I'm working out of a co-working space in town today, and walked into a bookshop during my lunch break. Yes, a physical bookshop. You know they still exist, right?

Unfortunately there is only one independent bookshop left in Swansea and that one is in the lovely seaside village of Mumbles, not in the town centre. I was walking around in Waterstones, one of the larger bookstore chains in the UK. The one in Swansea is inside the old Carlton Cinema, a historic building with a beautiful glass facade.

They do have a pretty extensive collection of books, and I noticed the following ones which piqued my interest:

Let me know in the comments if you can guess the thread that ties these authors together! 😜

#Reading

Comment on this post

Feature image

One spindle on the staircase in our new house is broken. How do you go about finding out a new one? I started googling and found out there is a mind-boggling array of spindle designs. I found one website that said they made copies of spindles of your existing staircase and you just need to send them a picture. I sent off all the required info and got back an e-mail very quickly saying that there's a minimum order quantity of 35. Yes, it would've have been great if they posted that detail on their website.

Ten websites and hundred of designs later, I discover that it's actually a very simple design called an Edwardian spindle, and there is a specific design that's from the “Richard Burbidge Trademark Range” that's very popular. I'm not 100% sure if ours is from that range, but at least I've now identified the design. This would be a great use case for Amazon's new Part Finder tool.

Comment on this post

Feature image

Man, moving house can be tiring, especially if you're trying to do it yourself. We've had great help from friends with the whole process, but there's still a lot of work to do.

A move is always an eye-opener to see exactly how much stuff you have. Why do we have so much stuff? Some of it is necessary, but I'm sure all of us have some things that we hold on to just in case. I hope I can get rid of some of the “just in case” stuff soon, as I just don't have the energy right now to try and decide what I want to keep and what I want to throw or give away.

One thing that I'm kind of excited about is that I want to re-read some of the books on my book case. I mean, I know I'm keeping them because I like them, so I should re-read them to at least see if that is still the case.

Comment on this post

Feature image

It's pretty early on Saturday morning, but I just realised that I probably won't have time later today to write a blog post. We're in the process of packing to move to the new house.

I rented a van yesterday. I've never driven one before, so that was an interesting experience. It was weird not being able to look behind you, as there is no rear view mirror. Apart from that, it didn't feel that different from driving a car.

I usually enjoy the part of packing where you can get rid of things, but it feels like I'm just stuffing things into boxes at the moment. Hopefully I will be able to properly go through things when I unpack and then be able to throw some things away. Well, let's get started!

Comment on this post

Enter your email to subscribe to updates.