Dutch / Nederlands
Site map

I write, therefore I am

With this variation on a famous statement by the philosopher Descartes, I would like to express that the act of writing about what happens in my life is important to me.

Sunday, November 17, 2024

Cooperative, polling operating system

I have been thinking about a tiny cooperative and polling real-time operating system that works with static, single instance tasks. ESP-IDF is based on FreeTROS, a real-time operating system for embedded devives. Although FreeTROS is called real-time, it has some dynamic behaviour due to dynamic memory allocation and interrupts. Nowadays, many peripherals are connected through serial communication busses, such as SPI, I2C, and I2S, where there are often multiple slave peripherals are connected on a bus. These peripherals often have complex operating modes that can be adjusted through control registers, and possibly also complex behaviour patterns. This has an impact on the real-time behaviour of microcontrollers that communicate with these peripherals. If you do not want to use interrupts, it means you have to use polling to see if an interaction with a peripheral has completed. If you develop an application that interacts with several peripherals, it is logical to have some kind of layering in more device oriented tasks, coordinating tasks, and more high-level tasks. If you do not use operating system like functions like queues, this results in tasks polling the completing of lower-level tasks. To avoid excessive polling, which takes a lot of resources, I have been thinking about a number of queue based approaches to avoid polling. Tasks often make use of finite-state machines, which are usually implemented with case-statements. If these are not compiled to branch tables they performance is lineair to the number of cases. To work around this, one could use functions for each of the states and cause the right function to be called for each state. This does match with the idea of tasks. I have started writing some code as an experiment: TinyCoPoOS.c. I also have been thinking about program generating the code for all the functions given a tasks declaration.

Planting fruit trees

In the afternoon, I helped a bit with the planting of fruit trees at Herenboeren Usseler Es. When I arrived the others just were taking a break, because some of them already started at nine in the morning. I mostly dug holes at the places where a tree had to be planted. Twice we had some rain. The first time with some hail and at 14:30, there was a rainbow. I am looking forwards how the trees are going to grow in the coming years.


Saturday, November 16, 2024

Harvest

Below a picture of the harvest (except for the 2 kilogram potatoes) that we received this morning from Herenboeren Usseler Es. (What you receive depends on how many 'mouths' you are paying for and personsl choices you make.)

The picture shows:

In the evening, I made some stamppot with the lacinato kale, two small red unions, a yellow bell pepper and some sauerkraut bacon. Conny made a salad with the outer leaves of the two red chicories.


Friday, November 15, 2024

Book

At 17:05:15, I bought the book HETHE BESTE VAN OF WIM T. SCHIPPERS written by Harry Ruhé in Dutch and English, and published by Centraal Museum in 1997, ISBN:9789073285446, from bookshop Broekhuis for € 45.00. This is a bilingual edition where the Dutch text is printed in red and the English text in green on top of each other. To read the text a transparent green and red sheet is provided in the front of the book that you have to put over the text. This book is the catalogue of an exhibition of the same name.


Thursday, November 14, 2024

Exhibitions

After work, I went into the city where I visited the exhibitions at Concordia. I saw the following exhibitions:


Monday, November 11, 2024

Links


Sunday, November 10, 2024

Wijlre

On the way Wijlre Conny and I stopped at the Netherlands American Cemetery and Memorial located in the village of Margraten and waled around the cemetery. We thought about the many soldiers that died during the liberation of Europe from the German occupation and how this relates to the current war in the east of Europe. We did like the design of the chapel with the window on the side.

Close to noon, we arrived at Kasteel Wijlre Estate for the exhibition Maintaining Its Spirit: Collection Marlies & Jo Eyck. I found the following works noteworthy:

We also saw the exhibition Growing Poetics by Thierry Oussou. We in particular liked the La Poessie in one of the rooms in the attic that he had filled with branches he found on the estate.

On the way home we stopt at the McDonalds in Drosten were we ordered two McPlant meals consisting of a plant based burger with french fries and a cola. This is at least the third time I visited this McDonalds. I visited it on Saturday, September 22, 2018 with Andy and on Friday, July 29, 2010 with Li-Xia.


Saturday, November 9, 2024

Bonnefanten Museum

Conny and I visited the Bonnefanten Museum in Maastricht. We first went to see the exhibition Maintaining Its Spirit: Collection Marlies & Jo Eyck at Bonnefanten. I found the following works noteworthy to mention:

From the exhibition Stanley Donwood and Thom Yorke: Maps of the New World I liked:

From the exhibition Małgorzata Mirga-Tas: This is not the end of the road, a solo exhibition with works by Małgorzata Mirga-Tas, I found the following works to be noteworthy:

From the exhbition Dream On, I found the following works noteworthy:

From the exhibition Collection Neutelings, I found the following painting noteworthy:

From the exhibition Truly Wicked: The Seven Deadly Sins visualised, I found the following works noteworthy (I was getting a bit tired and filled with images):

Furthermore, we walked through Studio Rossi with design of the museum building and walked around The Shooting at Watou by Folkert de Jong.

Maastricht

After we visited the museum, we walked through Maastricht taking some pictures. We brought a short visit to the bookshop Boekhandel Dominicanen, which I visited before on Sunday, July 21, 2019. It was already dark, but we took some pictures from the Sint Servaasbrug (a bridge over the Meuse river) before went to the Indonesian restaurant KapuláGa were we had the Kakanda rice table, which existsed of yellow yice, daging balado, rendang, smoor, ayam pedas, ayam opor, sate ayam, sambal goreng udang, tempe, poached egg, sayur lodeh, seasonal vegetables, gado gado, atjar, seroendeng, roedjak. We had some strawberry ice as an desert. We were very satisfied with the dinner.


Thursday, November 7, 2024

Cubes from Sheet: 11 by 11

I have this feeling that there are solutions for all cubes from a sheet problems, where at least one piece can be placed into, exists where at most twelve squares are unused for cubes. In the past weeke, I have been searching for counter examples. The program that I used, took a long time to find a solution with less than thirtheen unused squares for a square of eleven by eleven squares. Yesterday, I modified my Exact Cover program to also support positions with multiple vectors. This is a generalization of the Exact Cover problem. The multiple positions are needed to restrict the number of unused squares to an exact number. When I tried this program on the elven by elven square with seven unused squares, it found some solutions within half an hour. The first solution it found was represented as (on a single line):

S0_1_2_13_14_15|S3_4_5_16_17_18|S6_7_8_19_20_21|e9|e10|E11_12_23_24_25_36|E22_33_34_35_46_47|W44_45_56_57_68_69|W55_66_67_78_79_90|E77_88_89_100_111_112|e99|e110|D31_32_40_41_42_52|e30|W43_53_54_63_64_74|W65_75_76_85_86_96|E87_97_98_108_118_119|e109|e120|A28_29_38_39_50_61|Z26_27_37_48_58_59|S51_62_72_73_83_94|S49_60_70_71_81_92|K80_91_101_102_103_113|A82_93_104_105_114_115|A84_95_106_107_116_117|

This evening, I checked this solution and made the following drawing of it:

    +--+--+--+--+--+--+--+--+--+--+--+
    |        |        |        |##|##|
    +--+--+  +--+--+  +--+--+  +--+--+
    |     |        |        |        |
    +--+  +--+--+--+--+--+--+--+--+--+
    |  |        |     |     |##|     |
    +  +--+--+  +  +--+  +--+--+  +--+
    |        |  |  |     |        |  |
    +--+--+  +--+  +--+  +--+  +--+  +
    |     |     |  |  |  |  |  |     |
    +--+  +--+--+  +  +  +  +--+  +--+
    |  |     |     |  |  |  |     |  |
    +  +--+  +--+--+  +--+  +  +--+  +
    |     |     |     |     |  |     |
    +--+  +--+--+  +--+  +--+--+  +--+
    |  |     |  |  |  |  |  |     |  |
    +  +--+  +  +  +  +  +  +  +--+  +
    |     |  |  |  |  |  |  |  |     |
    +--+  +--+  +--+  +--+  +--+  +--+
    |##|  |        |     |     |  |##|
    +--+  +--+  +--+  +--+  +--+  +--+
    |##|     |  |     |     |     |##|
    +--+--+--+--+--+--+--+--+--+--+--+

I plan to refactor the code of my Exact Cover program such that it can be more easily be called from the program finding solutions for the Cubes from Sheet problems.


Tuesday, November 5, 2024

Book

At 18:40, I bought the book Prospects 2021: Mondriaan Fonds toont talent edited by Mirjam Beerman, written in Dutch, and published by Het Mondriaan Fonds in June 2021 from thrift store Het Goed for € 1.00. Before I there, I went to thrift store Rataplan. Although it seems they have more books there, I get the impression that they sell less books. These trift stores are for profit shops.

Link


Sunday, November 3, 2024

Links


Saturday, November 2, 2024

Colourful harvest

We got a rather colourful harvest from Herenboeren Usselere Es and I took a picture of a part of the harvest.

In this picture there are: a small puprple cauliflower, a romanesco broccoli, a fennel, two red cabbages, a green and a orange pumpkin, and a leaf of curly kale.

Link


Friday, November 1, 2024

63 years

I was born on Wednesday, November 1, 1961 at 9:45 in the morning (CET). That means that today, I will be 63 years according to the calendar and 23011 days old. But how old am I really? The tropical year, the time that it takes for the seasons to return, is said to be 365 days, 5 hours, 48 minutes, and 45.19 seconds. Yesterday, around 15:56:26 in the afternoon, it was 63 tropical years since I was born. But the tropical year is shorter than the sidereal year, the time taken by the Earth to orbit the Sun once with respect to the fixed stars, namely 365 days, 6 hours, 9 minutes, and 9.76 seconds. That means that, today at 13:22:14 it will be 63 sidereal years after I was born. The average anomalistic year, the time taken for the Earth to complete one revolution with respect to its apsides, is 365 days, 6 hours, 13 minutes, and 52.6 seconds. That means that, today around 18:19:13 it will be 63 average anomalistic years since I was born.

Double declaration?

I have been using the C progamming language (and later C++) for more than 34 years, but today I wrote something, I cannot remember having written before and it looks like a 'double' declaration of a variable:
extern int counter;
int counter = 0;
I am big fan of encapsulation and I like clean include files that hide implementation details that are not necessary for the users of the functions given in the header file. The implementation for a certain header file depended on a global counter that I did not want to include in the header file itself, but it needed to be incremented somewhere else and initialized to zero. So, I wrote in that other location, the main file (containing the main function):
extern int counter = 0;
And this resulted in a compile error, because you are not allowed to initialize a variable that is declared extern. Next, I changed the line into:
int counter = 0;
Now, I got a linking error saying that the other external definition (in the C file implementing the header file that relied on the counter variable) was not defined anywhere. This is because although it is defined in the main file, it was not defined as extern and thus not visible on the outside and thus becoming invisible for the linker that combines all the separately compiled C programs into one executable. It dawned on me that if I would have placed the extern declaration in the header file, it would have worked because then during the compilation of both C programs it would have been defined as extern and in the main program I still would have been able to initialize it. Although it is not common to see a 'double' declaration in a C file, like the above, and even looks a bit confusing, it is actually somthing that is done all the time, because the C preprocessor put both declarations into the intermediate file that is compiled by the actual compiler.

Links


Thursday, October 31, 2024

Book

At 17:25, I received the book jurrian van den berg: verzamelaar van dingen written and illustrated by Linda Rusconi in Dutch and published by Lecturis in November 2024, ISBN:9789462265271, from the Lecturis webshop for € 40.00.


Sunday, October 27, 2024

ESP32 I²C without interupts

In some bare metal embedded solutions you do not want to make use of interupts, because they potentially could introduce unpredictable behaviour. If you want to do this for the ESP32 it usually means that you cannot the high-level parts of the ESP-IDF because they are based on FreeRTOS that uses interupts. The implementation of the I²C driver makes use of interupts. The interupt handler is the function i2c_master_isr_handler_default in the file i2c_master.c. In this function i2c_ll_get_intr_mask is used to get the information about the interupt being raised and the function i2c_ll_clear_intr_mask is called to clear the bits. Before, in the function s_i2c_transaction_start, the function i2c_ll_enable_intr_mask is called with I2C_LL_MASTER_EVENT_INTR, which enables the interupts for: The I²C driver is a bit of an overkill for the most common use of the interface to communicate with slave periphials connected to the I²C bus, which usually consist of transfering packets of data not larger than FIFO send and receive buffers, which, according to the i2c_struct.h files, are 128 bytes in size. The I²C allows for eight commands to be processed in one run, which is enough for a combination of a write and read interaction, where you select a register in a periphial and read out its data. Each of the commands has a done flag (command_done field of the i2c_comd_reg_t). This can be used to see if an I²C sequence of commands has been completed by looking at the flag of the last command (usually a STOP or END command). But if some reason the execution of the sequence fails and this flag is not set, there is no way to know this, except than to conclude after a certain time-out periode that an error has occured. So, it seems at least if you do not want to resort to interupts. Although I do read otherwise on various forums on the internet, I wonder if it is possible to enable interupts and not install an interupt handler. Chapter 9 explains how the ESP32 has an interrupt matrix to allocate peripheral interupt sources to the two cores to be processed. In the function i2c_new_master_bus the interupt handler i2c_master_isr_handler_default is installed by calling the function esp_intr_alloc_intrstatus. The function is also given the address of the interupt status register and the constents of the irq field of the i2c_periph_signal for the specified I²C device. This value is defined in the i2c_periph.c file and is taken from the periph_interrput_t enumeration of periphial signals. The function esp_intr_alloc_intrstatus (defined in the file intr_alloc.c) tries to allocate one of the 32 interupt for periphials (at the designated core), and after having done some more initializations and bookkeeping calls the function esp_rom_route_intr_matrix to link the periphial to the interupt. If you do enable interupts for a certain periphial the contents of the matching INTERRUPT_COREx_SOURCE_y_MAP is used. For the ESP32-S3 the valid values for these registers are 0~5, 8~10, 12~14, 17~28, 30~31, which are all the values of the category 'Periphial' in table 9.2. However, the default value (on Reset) is 16, which is the number of the 'Internal' category 'Timer.2' interupt. Because a periphial interupt can be assigned to a particular core, it is logical that the value in the matrix of the other core is not changed. So, it seems that the value 16 is the value (or a value) to indicate that the periphial interupt is not processed for the given core.

Link


Saturday, October 26, 2024

Chasing The Dot

Conny and I went to Rijksmuseum Twenthe to see the exhibition Chasing The Dot with installations by Philip Vermeulen. We saw the following installations: The Chasing The Dot installation reminded me on The Brain Machine by Mitch Altman. It has a lot of flashing lights at various frequencies. Sometimes you start to see a dot. I think this is related to the fact that at the center of your retina there is a different concentration of rods and cones than in the other parts of the retina.

We also watched a short documentary about Philip Vermeulen and there also was a room with books and some (related) works. The works are:

Some of the books: Conny also took a picture of me when I was standing under a light in one of the dark rooms.

Next we saw the exhibition Gogbot x RMT (also called: The Tec Divide), which I already saw on Friday, September 13. We watched the works in the following order:

We also walked through the exhibition PLANETART ARCHIVES X Kees de Groot 1978-2003. At one of the tables, there was a booklet about Reset: Manifestatie over simulatie, animatie en games in 1998 that was organized by TARt. Maybe it was seen as a reset of the earlier TARt festivals, but it was a little different. Kees de Groot was one of the artist at this manifestation and the primary location was called 'Planet Art'. I never new about this 'connection' between the TARt festivals and GOGBOT. That manifestation did include games developed by students. Several GOGBOT festivals have included project by students as well.


Friday, October 25, 2024

19.0° Celsius

The temperature at Twenthe Airport has gone up to 19.0° Celsius, which breaks the previous record of 18.9° on this date in 1953.


Tuesday, October 22, 2024

Book

At 16:56, I bought the book On Anarchism written by Noam Chomsky in English and published by Penguin UK in 2013, ISBN:9780241969601, from thrift store Rataplan for € 0.50.

Verifying and documenting live-bootstrap

My project "Verifying and documenting live-bootstrap" is one the selected proposals eligible to receive a grant from NLnet Foundation in the April 2024 NGI Zero Core call, alongside 48 other exciting new projects. I have decided not to accept this grant, because I have lost interest in the project, having finished most of what I wanted to achieve and gave a presentation about it on September 29. I made an attempt to also run strace for the other supported CPU's, but failed to do so. I have created a page to present the results and give some background and history of the project as a kind of finalization of my investigations of the past years.


Monday, October 21, 2024

23,000 days

Today, it is 23,000 days ago that I was born. I decided to celebrate this special day by treat my colleagues on (small) cake. On Tuesday, January 25, 2022, I celebrated that I was 22,000 days old. On Sunday, 18 July 2027, I will be 24,000 days old.

Low-level SPI on ESP32-S3

I am reading Chapter 30 of ESP32-S3: Technical Reference Manual to understand how Low-level SPI works when using it in master mode, using 1-bit SPI, 4-line half-duplex mode, and CPU-controlled single transfer (no DMA), normal bit order, writing and/or reading at most 4 bytes (32 bits), only using DOUT and DIN and skipping CMD and ADDRESS (because we are using 1-bit SPI and there is no need to have those). My notes are:

Section 30.5.8.4 'Half-Duplex Communication (1/2/4/8-bit Mode)' explains how to set the registers for the desired SPI-usage. My notes:

The file spi_struct.h gives C struct definition for accessing the different parts of the registers. These are used in the file spi_ll.h. The following 'functions' can be of interest:

Note that the ports of the device that is being used, also need to be set.


Thursday, October 17, 2024

Links


Wednesday, October 16, 2024

Mushrooms on tree stump

This morning, just before leaving for work, I took some photographs in our backgarden of the mushrooms that appeared on the tree stump of the chestnut tree that we cut down two years ago. I have no idea what kind of mushroom it is, but I guess that it is a member of the family of polyporacae.


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.


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.


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).


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.


Tuesday, October 8, 2024

Link


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.


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.

Link


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

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 access and modifiy the 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 commands. 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.

Link


Sunday, September 29, 2024

Introduction

Diaries
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
2024
2023
2022
-- contact --

Family

Frans
Conny
Annabel
Andy
Li-Xia
Others
Pictures

Collecting

Books
Maps
Bookshelves
Art works
Computers
Cameras
Trips
Flights
Weddings
Funerals
Reading
Movies
Useless lists

Hacking

My life as a hacker
Signature programs
Software enginering
The Art of Programming
HTML to LaTeX
JavaScript
eXtreme Programming
Programs

Puzzles

Hamilton cycles
cutting sticks
Califlower fractal
more...


SARS-CoV-2

Tracking
Trends
Prediction
nextstrain.org/ncov



Email

The email address below, may only be used for private communications. This email address may not be put on any mailing list. I do not want to receive emails with advertisements of any kind. My email address is:

Privacy statement

This is a static website with no contact form and no way to add comments. It has no advertisements and no trackers. It does not use cookies. I am not using any method to analyse traffic to this website nor keeping any logs. I am not collecting personal data besides what is published on this website. If you want me to remove any personal data (including your name or link to your website), please contact me by above email address and I will make all effort to remove the data as soon as possible. I am private person and this website does not serve any economic purpose. All cost for maintenance are paid by myself. I do not receive any payments. The website is ad-free and does not have sponsored links.

Site statistics

If I did not count wrong, this site consists of 1067 HTML-files with a total size of 39,056,664 characters, having 82,765 internal links and 18,063 external links to (more than) 5,306 websites. (At least 797 of the external links are broken.) Furthermore, it contains 246 C/C++ program files with a total size of 5,827,946 characters, 11 MySample scripts with a total size of 85,207 characters, 3 PASCAL program files with a total size of 35,259 characters. and 2 Python program files with a total size of 3,764 characters. There are 70 text files with a total size of 772,678 characters. With respect to images, this site containts 1361 JPEG images (total size 62,234,590 bytes), 146 GIF images (total size 3,765,046 bytes), 95 PNG images (total size 2,302,310 bytes), and 2 BMP images (total size 3,727 bytes). With respect to sounds, it contains 14 WAV files with a total size of 389,002 bytes and 2 MP3 files with a total size of 8,717,982 bytes. It also contains 43 PostScript files (total size 308,387 bytes), 2 LaTeX files (total size 132,020 characters), 14 PDF files (total size 16,211,832 characters), 22 zip files (total size 2,487,335 bytes), 3 gzipped tar files (total size 52,345 bytes), 45 SGF files with a total size of 85,019 bytes, 168 KML files with a total size of 6,576,040 bytes, 1 bundle files with a total size of 99,918 bytes, and 2 EXE files with a total size of 38,340 bytes. It also uses 19 JavaScript files with a total size of 1,262,159 bytes, This leads to a total size of 153,821,278 bytes.

Copyright

Creative Commons License

I, Frans hold the copyrights of this and all other pages on this website. For this website a Creative Commons License is applicable. You may not use this work for commercial purposes. I consider all computer programs to be copyrighted by me under the GNU General Public License, unless stated explicitly otherwise. All quotes (text and program fragments) from other sources are excluded from this, and should be considered as copyrighted by their authors.