Previous Up No next

Diary, October 2024



Sun Mon Tue Wed Thu Fri Sat
          1   2   3   4   5
  6   7   8   9  10  11  12
 13  14  15  16  17  18  19
 20  21  22  23  24  25  26
 27  28  29  30  31


Thursday, October 3, 2024

Cutting pumpkins

Today I took pruning shears to work for the first time. After work at Herenboeren Usseler Es I helped cut and collect the pumpkins. The pruning shears were actually a bit oversized until we got to the 'family pumpkin', so called because of their size. This type of pumpkins were grown by Isabel Duinisveld from pumpkin seeds that she bought from the Marina Di Chioggia pumpkins in 2014. Isabel helped start Herenboeren Usseler Es last year.

ESP32-S3 I²C

In Chapter 27 of ESP32-S3 Technical Reference Manual describes the hardware components and registers that are used for the I²C bus. (On September 2, I wrote before about I²C.) For accessing the registers from C, the include file i2c_struct.h can be used. According to Table 4-3, one has to cast the address 0x6000F000 to i2c_dev_t* to access the 'I2C Controller 0' and the address 0x60029000 to access 'I2C Controller 1'. The include file i2c_ll.h gives all kind of helper functions to registers. Section 27.5 describes how the different command registers have to be used to send read and write I²C commands. It seems that the function i2c_ll_master_write_cmd_reg can be used to set the command. This function uses a value of the type i2c_ll_hw_cmd_t, which can be used to specify the various parts of the command. For examples how this function can be called, see the files i2c.c and i2c_master.c.


Saturday, October 5, 2024

Still life of the harvest

Below a still life of part of the harvest that I received this morning from Herenboeren Usseler Es or what I took from the giveaway table where other members can donate part of their harvest or where vegetables are harvested but not given out because they are too small or left over from a previous issue.

The picture shows:

State machines with a switch statement

While developing embedded software, you often have to deal with state machines, to implement non-blocking behaviour. If for example, one of the tasks for your embedded software is to read data from some UART and send it to another UART, you could have a function like:

void echo_infinite(UART *in, UART *out)
{
    while (1)
    {
        while (!data_available(in))
        {
            // wait
        }
        char ch;
        ch = read_byte(in);
        while (!ready_for_sending(out))
        {
            // wait
        }
        write_byte(out, ch);
    }
}

The above function will never terminate. That is no problem if that is the only thing your device has to do, but totally not acceptable, if your device has to do something else as well, for example, have a blinking LED. The traditional solution is to use a state machine and call the function implementing the state machine from the (never terminating) main loop. In case there is just one such task, one can make use of static define variables for the local variables. Otherwise, one has to define a struct for each such task and pass this as an argument. (See the page Machine independent implementation of Cooperative Multi-threading in C for how this could be done.) If you want to implement the above function echo_infinite as a state machine, you get something like::

void echo_state_machine(UART *in, UART *out)
{
    static char ch;
    static int state = 0;
    switch (state)
    {
        case 0:
            if (data_available(in))
            {
                ch = read_byte(in);
                state = 1;
            }
            break;
        case 1:
            if (ready_for_sending(out))
            {
                write_byte(out, ch);
                state = 0;
            }
            break;
    }
}

This code looks rather different from the above code. For this simple case, with only two states, it is probably not that difficult, but in case you have something like ten states, it can quickly turn into Spagetti code, that is difficult to follow, could have dupplicated code, and could have subtile bugs. In case the function implementing your task had no switch-statements and there is but one instance of your task, one could write the following code using some defines that are going to be explained below:

void echo_async(UART *in, UART *out)
{
    START_ASYNC
    while (1)
    {
        while (!data_available(in))
        {
            WAIT
        }
        static char ch;
        ch = read_byte(in);
        while (!ready_for_sending(out))
        {
            WAIT
        }
        write_byte(out, ch);
    }
    END_ASYNC
}

Notice that this code looks very much like the initial version. Note the use of static before the definition of the local variable ch. The defines one has to use, are the following:

#define START_ASYNC static int state = 0; switch (state) { case 0:
#define WAIT state = __LINE__; return; case __LINE__:
#define END_ASYNC }

These defines make use of the fact that the 'case' statements belonging to 'switch' statement may occur everywhere in the block following the 'switch'. In a sense, the 'switch' statement acts like a kind of 'goto' that can jump everywhere in the code belonging to it. It also makes use of the fact that the '__LINE__' macro returns the number of the current line. Note that they are replaced with the line number of the line where 'WAIT' is used, not where it is defined, according to the standard rules of how the C-preprocessor works. See the program D241005.c for an example that uses the above functions, where the functions echo_stm and echo_async are called a hunderd times, which is not always enough to print the string "Hello World!". The programs accepts a number as an argument to be used for initializing the random generator. (Find a number that makes all the functions print the whole text.) After the above two functions are called from main, the function echo_infinite is called, which never terminates, meaning that the program has to be terminated for it to end.

If one does want to use a 'switch'-statement in the code, one could use a combination of a switch statement at the start of the function and 'goto'-statements to labels matching the various places to wait. This does recuire one to number the states explicitly, which requires some additional work and bookkeeping, but it could help when implementing unit tests. When using C++, one can replace the static variables with private members of the class the method belongs to. This technique can be used to define iterators that are implemented as co-routines that yield results whenever needed. For a example, see the next method of the class InlineIncludesIterator in the program kaem_parser.cpp. For a more detailed description of all the possible ways to implement co-routines, see also: Coroutines in C.


Sunday, October 6, 2024

Seed pods in magnolia

This afternoon, after we went on a walk in the neighbourhood, I spend some time trimming some bushes in the front garden with a hedge trimmer. I also did some work on the magnolia and spotted some red seed pods as can be seen in the picture below.

I am thinking about when to harvest them. If I harvest them now, the seeds might not be mature enough. It looks like the fruits have not come out yet. If I wait too long, the seeds might be eaten by some birds and I will not be able to harvest the seeds. In 2013, it was on November 25 that we harvested the berries. I think, I am going to keep an eye on it for the coming week.


Friday, October 11, 2024

Magnolia seeds

Last Monday, I already harvested one of the berries from a seed pod that had partly opened. I kept it on my laptop. I continued checking the other pods. On Thursday morning, I closed my laptop not realizing that the berry was there. When I opened it in the evening, I noticed that it had crushed the berry and revealed the seed. I placed the seed in a small pot with potting soil. This morning, I wanted to show the pods to Conny, but when I did so, the end of the branch with the pods, broke off, probably from the location where the flower used to start. I noticed that there already where two cracks at in the two remaining pods. In the evening, I opened the cracks, took out the berries, and opened them to remove the seeds. I tasted a bit of one of the berries, but it did not taste nice. (I immediatelly wondered wether they are poisonous, but this seems not to be the case.) I potted those two seeds as well. I have wrapped the pots in plastic bags and placed them in our shed.


Saturday, October 12, 2024

Going into the city

When I biked on the road called Spoordijkstraat, which means railroad dike, I noticed some plants growing up against the sheet pile that was installed in the past year for the bike 'highway' running from Hengelo to Enschede. The YouTube video Bouwteamproject Aanleg F35, traject: Twekkelerzoom - Centraal station, Enschede shows an animation of the design of the bike path and the sheet pile starting from 0:59. Below one of the pictures I took.

At 13:44:26, I bought the booklet AKI Schilderlichting 2008 written by Joris Geurts, Kars Persoon, Kees Smits, and Elly Strik in Dutch and German, and published by AKI-ArtEZ Enschede in 2008 from Het Goed for € 0.50.

At TETEM art space, I saw the Model Collapse exhibition by Cyanne van den Houten and Ymer Marinus, who are part of the Telemagic collective. Before I entered the immersive exhibition, I was told that the exhibition is not about AI, as the title of it refers to concept of model collapse, but about how to get an AI like ChatGPT, but about how to get there. According to the description it 'depict the landscape from which generative AI emerges. Revealing its self-consuming origins in extraction of the earth's resources and data through relics, artifacts and stories from the past.' I was anticipating to learn some more about how these Large Language Models are created, but when I entered the exhibition I was a bit confused about it. There was a large screen with some text and about ten statue like objects with lights, buttons and displays. On was covered with a small displays that I found quite interesting.

At Fotogalerie Objectief, I saw the exhibition People Matter with photographs by Peter van Tuil and Frans Rentlink. From Peter van Tuil there were photographs from his books Ergens: Malaga 2023 and HUIS & HABITAT: Pieter en WillyPeter. The later is about the reclusive artist Pieter Derksen. Ingrid Hendriksen also took pictures of him with some text in English, which can be viewed at: (At home with Pieter Derksen: The reclusive artist. Frans Rentlink had a series of portrets of the surrealistic painter Charles du Bois and a friend of him called Johan.

At Concordia, it was quite busy with people visiting the Sustainable Fashion Experience Enschede. I first looked in the front room, where the exhibition Joystick by Madison Bycroft (on Instagram) was held. Next, I walked around the area where Kira Fröse and Marthe Zink are working on the Doublet #6 exhibition and then I went upstairs to have a second look at the Triangle in Square, but there was someone making some recording, so I did not walk around. I felt like the video's being displayed looked different. Then I heard some singing downstairs and it turned out that the gay men's chorus Soorten & Maten were practice singing the song 'Hotel California' (if I am not mistaken) as a warm-up for the performance they were going to give later. I presume as part of the opening of the exhibition It gets better by Tim Vischer, which is part of the Rainbow Days event. I left before the opening (also not being aware when it was).


Sunday, October 13, 2024

Wind direction graph

I noticed that the wind direction graph that is shown when you select 'Expertpluim' at the Weer- en klimaatpluim en Expertpluim page on the website of the Royal Netherlands Meteorological Institute, now has been improved like I did on July 29, 2022. I noticed that they did not use the solution (more a hack) that I used on my page. I have not figured out how they implemented it. Maybe there is now an option in the HighChart library for this.


Monday, October 14, 2024

C/2023 A3 (Tsuchinshan-ATLAS)

This evening, Conny and I biked to the country road called Borweg. (This road is named after a stronghold build by an Italian named Bernardino Cernaego who married Anna van Scheven as is mentioned on May 20, 1585.) We went there in the hope to catch a glimse of the comet C/2023 A3 (Tsuchinshan-ATLAS). When we arrived it was too light at the horizon. After some time, I thought to see a faint light with some line going up to the left. I took some pictures, one of which is shown below, in which the faint light of the comet is visible.


This months interesting links


Home | September 2024