With a socket created, and a message sent, the next step in our networking journey is to receive data.
Continue readingCategory Archives: Python
sendto system call from python
Once we open a socket, we probably want to send and receive data across it.Here is the system call we need to make in order to send data as I wrote about in my last post:
c = sendto(sd, buf, sizeof(buf), 0,
(struct sockaddr *)&addr, sizeof(addr));
Continue reading socket system call from python
While the Python socket API is mature, it does not yet support MCTP. I thought I would thus try to make a call from python into native code. The first step is to create a socket. Here is my code to do that.
Note that this is not the entire C code needed to make network call, just the very first step.I did include the code to read errno if the call fails.
#!/usr/bin/python3
from ctypes import *
libc = CDLL("/lib64/libc.so.6")
AF_MCTP = 45
SOCK_DGRAM = 2
rc = libc.socket (AF_MCTP, SOCK_DGRAM, 0)
#print("rc = %d " % rc)
get_errno_loc = libc.__errno_location
get_errno_loc.restype = POINTER(c_int)
errno = get_errno_loc()[0]
print("rc = %d errno = %d" % (rc, errno) )
print("OK")
Running this code on my machine shows success
# ./spdm.py
rc = 3 errno = 0
OK
Querying the PCCT in Python
The Platform Communication Channel Table contains information used to send messages in a shared memory buffer between the Operating System and other subsystems on the platform. Typically, the Channel has an interrupt defined that is used to tell the other subsystem that there is new data available.
Recently, I’ve been working with a couple entries that are of a newer type. In addition to the shared memory region and the interrupt values, the PCCT entries for type 3 and type 4 channels also have a series of registers. Where before the PCCT entries were normalized, now they are hierarchical. This makes them a little harder to scan with the human eye to confirm that the proper values have been recorded and read.
To simplify development, I build a simple script.
Continue readingWhy is ABC Notation not ABC…?
When we read we begin with
A.B.C
When we sing we begin with Do Re Mi
–“Do, a Deer…” THe Sound of Music
Western music has coalesced around the major scale. Which is really a pity, because western music notation was built around the natural minor scale.
Continue readingErrors running Keystone pep8
The command to run the formatting tests for the keystone project is:
tox -e pe8
Running this on Fedora35 failed for me with this error:
Continue readingHow do you keep the Kolla Playing?
(With apologies to Bergman and Legrand)
I need to modify how the ipxe container mounts directories. Why? AARCH64 iPXE stuff. Specifically, I need to get my own version of a file into the directory that a container mounts when it is running. How do I do that? I don’t know yet, so I am going to look.
Continue readingGenerating a clouds.yaml file
Kolla creates an admin.rc file using the environment variables. I want to then use this in a terraform plan, but I’d rather not generate terrafoprm specific code for the Keystone login data. So, a simple python script converts from env vars to yaml.
Hidden Tuples
If you are going to write a Sudoku solver, write a brute force, depth first search. You can get it running fast enough.
But what if you couldn’t? What if the puzzles were so big that solving them by brute force was not computationally feasible? A Sudoku puzzle is build on a basis of 3: The Blocks are 3X3, there are 3X 3 of them in the puzzle, and the rows and columns are are 9 cells (3 * 3) long. This approach scales up. If you were to do a basis of 4, you could use the Hexadecimal digits, and have 16 X 16 puzzles.
A Basis of K leads to a puzzle size of (K^4). The basis can be any integer. A Basis of 10 would lead to a puzzle size of 1000.
The Sudoku puzzle shows exponential growth. https://en.wikipedia.org/wiki/Combinatorial_explosion#Sudoku
What could you do for a complex puzzle? Use heuristics to reduce the problem set to the point where a the brute force algorithm can complete.
Continue readingLong Refactoring: Completing the Iterator
Now that the algorithm does not need a new test_board every time, we no longer need to treat the Node object as a Flyweight. We can move the board into the Node object and remove it from the parameter list of all the functions that operate on it.
Continue reading