211 IX: IX Software Family Assets (211.html)

Keywords

ICH180RR "IX Software Family" Blink GED "ISO9003 Version Control" log environment n.sh OnBoard pir2.sh IXp.sh "IX macro" prepIX CD2 textpack package "hash totals" md5 ver version "version number" requires benchmark performance RTC CR2032 NVMe 2230 SSD Bourne shell bash ix_grep() grep "Misc. IX functions" "IX Software List"

/KeywordsEnd

(To enlarge .....Click it)
thumb: IXimage.jpg
IX or (IX by DC) or "|><"


This article is a part of the IX family of software.

Introduction

With the IX Software Family, the author is contributing a powerful addition to the Python scene. The IX macro facility can be a useful new tool for every Python programmer. Replacing the "import" statement by "requires" adds both version control and hash totals to this important Python statement. The option of including or excluding all the internal function code enhances debugging and yet simplifies the final code set which facilitates code reviews. The "n.sh" shell command provides an important summary of all the modules in the finished program.

The "requires" function is an integral part of the IX Software Family. More is said about this whole IX Software Family in Source 1 below.

	The author apologizes for the complexity of the "requires" 
	functionality used to "import" functions into a main program.  
	But powerful software concepts are seldom very simple to 
	understand and use.
	
The first image under the heading "Other Related Thoughts" (far below) depicts my Cytron "CM4 Maker Board" that houses a Compute Module 4, an SSD drive, a microSD card, the 40-pin GPIO connector and many connectors allowing it to be the hub or core of a tiny but powerful Raspberry Pi computer. It has BlueTooth and connectors for Ethernet, a microSD card and a Real Time Clock (RTC) permitting it to operate connected to the web or in isolation. The optional RTC requires an on-board CR2032 "coin" battery. The CM4 WiFi capability is dependant upon the particular Compute Module 4 that is in use. It can boot from either the SSD drive, the microSD card or the eMMC on the CM4. The firmware on the CM4 has the ability (Source 04) to bootstrap itself (in the manner directly from the Ethernet) as does the Pi400. An audio jack provides Left and Right Audio. My computer (in this image) boots itself directly from the NVMe SSD. (Note that the "CM4 Maker Board" does NOT support SATA drives.) The biggest deficiency of the CM4 is perhaps the absence of any USB-3 connectors. This slows down the best SATA drives that would benefit from USB-3 speeds. It has a boot/run switch to permit the operating system to be copied to the microSD card (or eMMC on the CM4) via the USB-C power connector from a "master" computer (and then run) like the Raspberry Pico. As of November 2023, my computer currently boots up the latest Linux version of the "32-bit Bookworm" Operating System. "Bookworm" is the Linux Operating System currently recommended for use with the Raspberry Pi computers. It should be noted that almost every GPIO pin is operational, either being connected to a device to or an on-board connector. The notable exception is the group of SPI pins (GPIO7-GPIO11) which can only be accessed via the GPIO pins themselves. As can be seen in the image below, each of my computer cores is identified by the right-most 4 digits of its serial number. The microSD card is only usable with a Lite CM4. A Lite CM4 has no internal eMMC. With 2 mouse clicks, the "PINOUT DIAGRAM" shown below can be enlarged to super-high-resolution permitting us to examine this super board in great detail:

(To enlarge ..... Click it)
(Once enlarged ..... Click again for Hi-Res)
thumb: CM4 Maker Board Pinout.png
CM4 Maker Board Pinout

Note that Grove I2C and Maker I2C share all 4 pins.

Annotated (Alphabetical) Index of My Software Repository

The following sets of programs (mostly written by the author of this article), wherever possible, have been installed on my main SABRENT01 512 GB SSD drive. This tiny (yet high-capacity) drive is expected to become the central Repository of "all" of the author's Raspberry Pi software. Most of this software runs on a Raspberry Pi computer. (Some run on other microprocessors. Thonny handles microprocessors as clients very well.) It is the intention of the author to migrate all of his source code into this repository. Of course, any important repository must be backed up regularly.

As with many amateur "home-brew" projects, many of the author's bigger projects have been interrupted and are proceding slowly.

The ix pkg of Python functions: ix_pkg.py

Source 09 is a package containing a partial list of IX functions as of 2023 L Dec 01. To use it, the final name should be "ix_pkg.py". Many web browsers automatically invoke the relevant software program according to the extension. I find this to be particularly perplexing when the extension is ".py". Most of the time I want to simply download a ".py" file without invoking Python to run it. For this reason, I try to always rename a ".py" file into a "_py.txt" file so that Python will NOT be invoked. After downloading one of these files, simply change the suffix from "_py.txt" to ".py" and it will be fully usable as a Python package of functions. To see the list of functions in this package, use the "sh n.sh . . ." CLI command. This package currently contains the following functions:
	getSub()
	getSub_v00()
	initCD2()
	ix_grep()
	ix_grep_v00()
	ixTestB()
	ixTestC()
	preParse()
	preParse_v00()
	readCD2()
	replSub()
	replSub_v00()
	requires()
	
As can be seen, this is a small number of the IX functions. But they have all been tested. Many of them have been converted to function pairs, to make them ready for use by prepIX_I and requires().

requests() and requires()

Recently, I have been looking for the code where I developed many of the concepts pertaining to requires() which formerly I called requests. Finally, I found the original code. It is now in Source 10 of this article. The name of the program is "buildMain_WioT_v01o01_2023EMay15_py.txt". I thought that I had lost it! I was loooking for "requests" and "requires", when I should have been looking for "prepIX".

Last Minute Thoughts

These pertain to IXp, the author believes???

1. Use "%20;" as a placeholder, instead of "&20". Permit user to choose: other options are "&nbsp;", "%20" or "&ix_sp|".
2. Be sure to warn if the choice exists in the incoming string.
If it exists, use "&ix_sp|", which the user must not code.
3. Replace the "%20;" with a real space at the end of the program.

ix_grep.py

The webmaster has recently created a useful function that performs a grep-like lookup of a phrase in an external file. It has been designed to resemble the Linux "> $grep phrase file.txt". An example of its usage in Python code is shown below:
	phrase="Raspberry"
	file="/home/pi/Desktop/IX_assets/ix/ix_eDict.txt"
	value = ix_grep(phrase, file, "=",'"',"#")
	
The phrase is the character string that is the target string to be searched for. It is possible for ix_grep to return the whole row containing the target string, but the invocation of ix_grep shown above only returns the value in the last row that contains the target string. The file that is searched must be a fully pathed file name, eg "/home/pi/Desktop/IX_assets/ix/ix_eDict.txt". If a row of this file contains the specific text, the value in that row will be returned. The row with this specific text in the file will work fine: "Raspberry=Pi4", it will return the value "Pi4" without any double quotes. The third parameter is "=" which defines the character that splits the phrase and the value. The value will be stripped front and back of any spaces. If the fourth parameter is not null, then it will be stripped front and back also. The fifth parameter defines a comment line in the file. Any rows beginning with this comment character in the file will be ignored. The ix_grep() function differs from the Linux "grep" in that it only returns the LAST record that contains the target string, not ALL the records.

The names of parm3, parm4 and parm5 are splitStr, stripStr and commStr.

Many users of ix_grep() will want to "look up" the value of a Control parameter stored in the "ix_eDict.txt" file and perhaps compare it to an expected value. The Control parameter might be "Raspberry". Its value might specify the model of Raspberry computer currently being used, eg "Pi4B". This can be tested using the single ix_grep statement shown below:
	file="/home/pi/Desktop/IX_assets/ix/ix_eDict.txt"
	if "Pi4b"==ix_grep("Raspberry", file, "=",'"',"#") :
            print("The current Raspberry model is 'Pi4b'.")
	
The ix_grep() function has another interesting use. It can return a Python list of ALL the records in the file when called as shown below:
	phrase=""
	file="/home/pi/Desktop/IX_assets/ix/ix_eDict.txt"
	recList = ix_grep(phrase, file, "",'',"#")
	
The above invocation of ix_grep() [with a null phrase] returns a proper Python list of all the uncommented records in the file. This usage is intended to do most of the work to load eDict from ix_eDict.txt. Note that eDict is the entity control dictionary used by the IXp macro preprocessor.

A small test program for ix_grep can be found in Source 11. In the next source, Source 12, the IX function pair can be found along with some other current IX functions (as of 2023LDec03). It accompanies many other IX functions. A brief Terminal session using Test_ix_grep.py is shown below:
	> $python3 Test_ix_grep.py
	> Hit Cr to make list.
	> ?Raspberry
	   ** Result: Pi4B
	> ?
	
This is the result if the row "Raspberry= Pi4B" exists in "ix_eDict.txt" (shown below and in Source 17 as of 2024BFeb07) . Note that the result returned (when a non-null phrase is the target) is always a string. A result of "False" will be a string, not a boolean variable. A result of "123" will be a string, not an integer variable.

	ix_eDictDate= 2024BFeb07
	ix_EntityPriorityFromCLI= 6
	ix_EntityPriorityFromEDictTxt= 5
	ix_EntityPriorityFromInLine= 4
	ix_EntityPriorityDefault=3
	ix_isDisplay_eDict= True
	#ix_isDisplay_eDict= False
	ix_isIncludeTrailingIDstamp= True
	ix_isLimitRequiresTo_v0= True
	ix_isPrependRequiredFunctions= False
	ix_isShow= False
	ix_isSuppressComments= True
	ix_isUsePythonImport= False
	ix_sp|= " "
	myName= DavidCole
	myEmail= David4ColeCanada@gmail.com
	myCellPhone= 613-875-7767
	Raspberry= Pi4B
	/ix_eDict.txt stored in Desktop/IX_assets/ix
	
The ix_grep() function can be used for many purposes. For example, the function defined as "def getSub_v01(" should appear in ix_pkg.py if version 1 of the getSub() function can be used. The following Python REPL statements in Terminal will provide the answer:
	> $python3
	>>>phrase="def getSub_v01("
	>>>file="/home/pi/Desktop/IX_assets/ix/ix_pkg.py"
	>>>import sys
	>>>sys.path.append("/home/pi/Desktop/IX_assets/ix")
	>>>from ix_pkg import ix_grep
	>>>from ix_pkg import ix_grep_v00
	>>>result = ix_grep(phrase, file, "",'',"#")
	>>>print("result:"+result+":")
	
It should return "None". Changing "_v01" to "_v00" should return a result. (This will work when Issue 5 (below) has been resolved.)

Unresolved Issues in ix_grep()

(as of 2024BFeb07)

Issue 01 (as of 2023LDec04): If splitStr is defined, but is absent in the record,
ix_grep should (optionally) return the whole record (not "None"). This option can be
specified in ix_eDict.txt . (This option name is ix_isWholeRecif_splitStrAbsent).
Issue 02 (as of 2023LDec04): If file is null, it should default to
"/home/pi/Desktop/IX_assets/ix/ix_eDict.txt" .
Issue 03 (as of 2023LDec04): If parm1 (targetStr) is null, and splitStr is not
null, ix_grep should return a Python dictionary (not a Python list) of only the rows
that ARE split. This dictionary will often be eDict. If commStr is not null, comment
rows will be ignored.
Issue 04 (as of 2023LDec04): The target string is compared to the whole phrase on
the left side of the splitStr. It could optionally match any substring on the left or
could match any substring of a non-split record.
Issue 05 (as of 2023LDec04): The file for the target string search is limited
to "ix_eDict.txt" in the current folder. It should search "file" instead.

Creating A Raspberry Pi SSD (and other Misc. IX functions)

Source 15 describes the steps that the author takes to create a new SSD for a Raspberry Pi. Source 16 is the configuration of folders that the author loads onto a new Raspberry Pi SSD as of 2024BFeb06. If the SSD will be connected to a RPi 5B via PCIe, it is necessary to add more boot code. See 210.html for the necessary changes to rpi-eeprom0config.

A former (earlier, dated 2021BFeb12) library of ix_pkg.py functions (in article 155) can be found in Source 18. A former (earlier, dated 2023JOct11) list of IX programs (from article 196.html) can be found in Source 19. A fairly complete (dated 2023DApr07) list of IX functions and Python programs can be seen in Source 20. An earlier "Most comprehensive Python function list (as of 2022CMar20)" can be seen in Source 21. Article 174.html describes many IX functions and programs. Article 215 (Source 23) is being created so as to house a complete list of Python functions created by (or used by) the author.

Other Related Thoughts

(To enlarge .....Click it)
thumb: IMG_0051.jpg
Cytron Maker CM4+Sabrent SSD

The CD2 dongle can barely be seen.

Note that the Compute Module 4 shown above has WiFi (no Ethernet cable) and eMMC (no microSD card). It also has 4 GB of RAM. It boots directly from the 512 GB SABRENT NVMe SSD. I plugged a 12v power supply into the barrel connector on the CM4 Maker Board. It worked at first, but seems to have broken the board when I unplugged it and plugged it in later. Beware!

How to set the date/time on a Raspberry Pi (and on the RPi 5B RTC)

See Source 06 for instructions from Raspberry Pi Tips. But, Cytron, in Source 07, says the easy way is to use Terminal and type:
> $ sudo date -s 'YYYY-MM-DD HH:MM:SS'
The above command WILL set the RPi system clock to the time specified, but it will not transfer this RPi system clock time to the hardware Real Time Clock (RTC). Doh! Source 06 trys to explain how to use the RTC. On Raspberry Pi OS systems there is a "fake-hwclock" that is used when the time cannot be read via the Internet. It seems to remember the last time that a file was written to a disk or uSD card. Then the next reboot is presumed to happen a short while after this last file was written.

They (at Cytron) say: The command to do this (set the hardware RTC on the RPi 5B) is:
> $ sudo hwclock -w
The command to do the opposite (set the system clock from the hardware RTC on the RPi 5B) is:
> $ sudo hwclock -s
The [failing] command to read the hardware (RTC) clock is:
> $ sudo hwclock -r
>   hwclock Cannot access the Hardware Clock by any known method. 
>   hwclock Use the --verbose option to see . . . . for an access method.
> $ sudo hwclock --verbose
>   . . . . 
>   . . . . 
>   no usable clock interface found
Doh! Cytron Doh!
You say I2C-10 is used by default.
The RPi configuration says that I2C is turned ON.
There is a CR2032 coin battery installed.
But I have NOT flashed the EEPROM of the CM4, because the OS is being booted from the SSD.
What am I doing wrong, Cytron?
I don't really need the RTC, because I can plug an Ethernet cable into the CM4 Maker Board. Then the clock gets set automatically from the Web by Linux. Or I can use another CM4 board that has WiFi. So this issue with the Cytron CM4 Maker Board's RTC is not a roadblock (for me at least).

How to cd within a Bourne shell (bsh)

This needs a detailed explanation. So go to Source 13.

Sources

Video Sources

Video Source V211:01: FINALLY! NVMe SSDs on the Raspberry Pi (13:30m) by Jeff Geerling c 2023 K Nov 16

Web Sources

Web Source S211:01:www requires_v01_py.txt by D@CC on 2023JOct26
Web Source S211:02:www n.sh by D@CC on 2023KNov27
Web Source S211:03:www Test_readCD2_py.txt by D@CC on 2023KNov27
Web Source S211:04:www Find: "Install Raspberry Pi on microSD Card" by Abdul Salam A Haris of Cytron on 2023CMar08
Web Source S211:05:www "Spico" and TheSilentMonitor by D@CC on 2022 H Aug 16
Web Source S211:06:www .. Set Date & Time on RPi by RPi tips before 2023KNov30
Web Source S211:07:www Setup RTC by Abdul Salam A Haris of Cytron on 2023CMar09
Web Source S211:08:www requires_v01_py.txt by D@CC on 2023KNov30
Web Source S211:09:www ix_pkg_py.txt by D@CC on 2023LDec01
Web Source S211:10:www buildMain_WioT_v01o01_2023EMay15_py.txt by D@CC on 2023EMay15
Web Source S211:11:www Test_ix_grep_py.txt by D@CC on 2023LDec03
Web Source S211:12:www ix_pkg_2023LDec03_py.txt by D@CC on 2023LDec03
Web Source S211:13:www . . . cd Command in Bash Scripts by baeldung on 2020GAug13
Web Source S211:14:www show_py_py.txt by D@CC on 2023LDec05
Web Source S211:15:www Create_New_SSD.txt by D@CC on 2024BFeb06
Web Source S211:16:www Suggested_IX_folders_2024BFeb06.txt by D@CC on 2024BFeb06
Web Source S211:17:www ix_eDict.txt by D@CC on 2024BFeb07
Web Source S211:18:www A Former ix_py.txt Python Library for Raspberry Pi (155.html) by D@CC as of 2021BFeb12
Web Source S211:19:www IX Family of Software from 196.html by D@CC as of 2023JOct11
Web Source S211:20:www IX functions Python List from 190.html by D@CC as of 2023DApr07
Web Source S211:21:www MOST COMPREHENSIVE PYTHON FUNCTION LIST from 174.html by D@CC as of 2022CMar20
Web Source S211:22:www Complete List of Software For Raspberry Computers by D@CC as of 2024BFeb07
Web Source S211:23:www IX Raspberry Software Repository (215.html) by D@CC on 2024BFeb19

/SourcesEnd


There is a way to "google" any of the part-numbers, words or phrases in all my articles. This "google-like" search limits itself ONLY to my articles. Just go to the top of "Articles by Old King Cole" and look for the "search" input box named "freefind".

Click here to return to Articles by Old King Cole

Date Created:2023 K Nov 27
Last Updated:2024 B Feb 07

All rights reserved 2024 by © ICH180RR

saved in E:\E\2022\DevE\MyPagesE\Globat\ePhotoCaption.com\a\211\211.html
backed up to ePhotoCaption.com\a\211\211_2023KNov27.html

Font: Courier New 10 (monospaced)
/211.html