hive.wiki

Developer Page


ANSI C: #


  • To assist in finding segmentation faults:
valgrind -s --leak-check=yes <<cmds and args>>


<<cmds and args>>
 - commands related to building (e.g., make)


  • YouTuber Jacob Sober ... excellent teacher (Clemson Univ); learned a lot from him






Developer Page /

html5






Center dot: "&#8729; / &middot; / &centerdot;

Subscript: <sub></sub>  


Superscript: <sup></sup>  


&deg; &micro; &sect are all good to know ... they are called'HTML entities'


Click here to see all the HTML 5 entities and here for HTML 4 entities ... example, &mu; or &micro; in html produces μ in the browser.



Developer Page /

TiddlyWiki Info


Wiki Settings: #

  • Custom JavaScript, html and CSS can be added to the Wiki Settings page


  • There seems to be some persistence issue




Linux Commands


alias - creates command shortcut --including cmdLineParams--

apt-get (apt) - install package

*** Update OS:

sudo apt-get update


sudo apt-get upgrade

  • install, remove, update, upgrade, autoclean, autoremove


awk - string manipulation from cmd-line (text processor)

brightnessctl - control backlighting brightness (another possibility is brightness-udev


cat - list contents of file 

cat /proc/cpuinfo - get info about board and CPU

chmod - change file permissions

Order UGO {(U)ser / (G)roup / (O)ther; (R)ead - 4, (W)rite - 2, and E(x)ecute - 1


E.g., sudo chmod +743 <file_name>, where + means add permission 7 is R/W/X for User, 4 is R for Group, and 3 is W/X permissions for all others


chown - change file owner or group

df -h - file system disk space usage (-h human readable values MB, GB, etc.)


du - disc space usage (du -hxd1 / print space usage for root level folders w/ size) 

dmesg - print or control kernel ring buffer


fdisk - manipulate disk partition table (be careful)

sudo fdisk -l  ... lists information about the various file-systems

finger - user info lookup program

finger without cmd-line args, will list all users logged into computer

free -h - get amount of memory in human readable form


gdb - debugger

grep - print lines that match pattern specified


groups <options> <user_name> - list the groups a user belongs to


hexyl - another hex/ascii dump program

htop - displays running processes


ifconfig - lists network connection info


kill - send messages to processes (sudo kill -9 <process_number>)

ls - list directory contents


lsblk - list the block devices


lsof - list open files


lsusb - list USB devices (lsusb -tv verbose-tree form)


man - manual pages ... help 


nc - arbitrary TCP/UDP connections and listens (well, that is what the man-page says)


netstat - print network connection, routing tables, I/F stats, masquerade connections and multicast memberships

nano - simple text editor; command-line


nmap - network exploration tool and security/port scanner (highly configurable)
passwd - change user password

ping - send ECHO_REQUEST to network hosts

-s<blk>, where blk is packet size


-c<#>, where # is number of pings before terminating


ps - list processes currently running


pwd - print working directory


od - hexadecimal dump from file (od -tx2 select hexadecimal 2-byte units)


raspi-config - cmd-line configuration tool for Rasbian OS
reboot now - restarts device

rfkill - tool for enabling and disabling RF devices


rsync - remote (and local) file copy tool.  Used for copying and then removing the file (if copy successful) on a remote host

rsync [options] [src] [dst] ... [src] and [dst] format: <user_id>@<remoteHost>:<path/file_name>


For moving from [src] to [dst], use the --remove-source-files cmd-line option.

Show progress, use --progress cmd-line option.


scp - secure copy

scp  <source_file>  <destination_file>


  • source_file = [user@]SRC_HOST:file1;

  • destination_file = [user@]DST_HOST:file2


screen - screen manager with VT100/ANSI terminal emulation

^a (ctrl-a)  >> quit


^a + k  >>  kill screen


sed - stream editor


setserial - info about serial port specified << -G switch mentioned in notes w/o description >>


shutdown now - shutdown system immediately.


split - splits text file into pieces as defined by the operator


ssh - secure shell (terminal)

ssh-keygen - generate private/public key file 


ssh-copy-id - copies public key to remote host

  • Go to Secure Shell for more information on generating keys for auto-login feature.


stat - lists file or file system information

stty - change and print terminal settings


sudo - Super User do ... override with *root* access


tr - translates or deletes character


type <command> - lists location of <command>


uname -a - lists system info


usermod - modify a user account

sudo usermod -a -G dialout <usr_name> 

which <file_name> - list path of file seen by OS


xxd <file_name> - lists contents of file_name in hexadecimal form (-b outputs in binary)



Raspberry Pi Specific #

raspinfo - list tons of info about the Raspberry Pi


pinout - lists information about Raspberry Pi GPIO


Projects

No Page Content
Projects / Serial Comms /

GPS unit (BU-353S4)


  • GPS unit BU-353S4 is a USB connected all-in-one GPS unit.


  • Seen as /dev/ttyUSB0


  • lsusb -t lists tree view of USB devices visible; (driver=pl2303 is gps unit)
Prolific Technologies


PL2303 serial port


Mobile Action MA-8910P


  • do a hex dump: od -x < /dev/ttyUSB0 {does not work for BU-353S4}


  • use  xxd /dev/ttyUSB0 for BU-353S4, for a hex dump from the gps


  • Use putty to view data from GPS unit
sudo apt install putty


Setup putty
: from cmd-line, (a) putty, (b) setup as serial @ 4800 bps, (c) save config, (d) close, (e) reopen putty select saved serial config


  • $GPGGA NEMA sentence, most common; other common sentences $GPGSA, $GPGSV, $GPRMC


  • After establishing comms via putty, the cmd-line dump will work

Projects / Linux Specific /

Hostname Determination

  • Install nmap
sudo apt-get install nmap


nmap -A

nmap --resolve-all 192.168.1.*


Projects / Linux Specific /

Interesting Files


/etc/hosts


/etc/hostname


/etc/fstab


/etc/os-release - contains OS version


Projects / Linux Specific /

Linux Basics

  • Preceded command with a period (.), to execute the command within the current shell.


  • PATH is an environment variable; contains a list of folders, each of which are searched for executable programs when commanded.


  • Create or modify the .bash_aliases file to consolidate aliases.  Alias command structure:
alias <alias_name>='<set of commands>'



Projects / Linux Specific /

Misc Stuff


  • Empty Trash from cmd-line: rm -rf ~/.local/share/Trash/*


  • Unicode escape codes uxxxx, where xxxx is a four digit hexadecimal number.  Google for the codes.  Works in c type format statements.


  • --color=auto is a fairly common cmd-line arg





Projects / Linux Specific /

Mode S Decoder

* ModeSdeco2 - no longer in development, will only work on old Rasbian OS; outputs Beast mode


* dump1090-mutability - currently in development; used on Raspberry Pi 4 in attic (http://192.168.1.248:8080/)

** dump1090 can be setup for automatic start-up.  setup Linux system with 'sudo apt install dump1090-mutability' Then use "dpkg-reconfigure dump1090-mutability" or edit /etc/default/dump1090-mutability.


Custom Software  #

(modeSserver-client) ... <<bring in readme file from project Dev folder>>

Projects / Linux Specific /

Raspberry Pi


  • pinout - python program that gives info about Raspberry Pi GPIO (General Purpose Input/Output)





Projects / Linux Specific / Raspberry Pi /

Install ScreenSaver on Raspberry Pi

  • Update Raspbian OS:
sudo apt update


sudo apt upgrade -y


  • Install baseline Screensaver software:
sudo apt install xscreensaver


  • Use sudo apt install to install the following add-ons:
xscreensaver-data-extra


xscreensaver-gl


xscreensaver-gl-extra


NOTE: could use 'Add/remove software' under Preferences and search for 'screensaver'.

Projects / Linux Specific /

Setup Headless Linux Machine


Automated Setup  #

Use Advanced Options in the Raspberry Pi Imager; ensure ssh is enabled (link)



Manual Setup #

(Note - this series of steps were only tested on Raspberry Pi 4b)


  • Image SD card with desired Raspbian OS


  • In root partition, create a file named 'ssh'; leave the contents empty


  • To setup WiFi with local network: create file (not sure where) with the following contents

country=US


ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

network={ ssid="<<wifiAPname>>" psk="<<passPhrase>>" key_mgmt=WPA-PSK }



  • Default Raspbian OS user credentials: pi::raspberry


  • To change password use passwd on command-line


  • To change hostname of new computer: sudo nano /etc/hostname 



Projects / Linux Specific /

Shell Scripting


She-bang ... #! ... start script with #!/usr/bin/bash

if unsure about the location of bash, type which bash.



<<WIP - more to come>>


Projects / Linux Specific /

Startup commands

Info about where to put scripts or commands to execute at start up.



Method 1: /etc/rc.local #

Edit /etc/rc.local file ...  #

sudo nano /etc/rc.local
  • Insert commands before the 'exit 0'; statement.
  • Not a preferred method; needs more research


Method 2: ~/.bashrc #

Edit ~/.bashrc file #

sudo nano ~/.bashrc


Note - runs at startup and when a new terminal window is opened.  Started by .profile.



Method 3: ~/.profile #

Edit ~/.profile #

sudo nano ~/.profile



Method 4: put file in /etc/init.d directory #



Method 5: Systemd #

<<WIP - more to come>>



Method 6: crontab #

<<WIP - more to come>>



Projects / Linux Specific /

Systemd Research



  • Initial process that controls other processes.

Projects /

Mode S Gouge



Locally noted Mode S A/C Address (24-bit): #


  • A1BEFC; EmitterCode = 2 (Lifeguard/Medical); near hospital


  • A27330; EmitCat=B2 (Lighter-than-air); tail=N257TH; Raven Aerostar





Miscellaneous Info: #


MAGVAR near Patuxent River Naval Air Station is -11° or 11° W


WGS84 basestation: N38° 18' 29" by W076° 25' 51"


Mode S Parity Generator (CRC check gen function) = 0x1FFF409 (25-bits)



Military Mode Select: #


  • United States Military Mode S Aircraft Addresses: ADFC60 - AFFFFF


Logic Systems


[W.I.P.] 2024-02-06, this section is being roughed out as a course in Logic Systems Design (digital systems).



Outline: #

(VHDL instruction embedded)

  1. Digital Data
  2. Boolean Algebra
  3. Gates
  4. Implement Logic Equations
  5. Optimization (k-map, equation manipulation, etc.)
  6. Medium Scale Integrated Circuits
  7. Arithmetic Processing 
  8. Introduction to Sequential Logic
  9. Latches and Flip-Flops
  10. Timing Diagrams
  11. Finite State Machines (FSM)
  12. FSM as Control for MSI Components
  13. High-Level State Diagrams



Logic Systems /

Digital Data

Numbering Systems #


The most familiar numbering system is the decimal number system. Computers and other digital systems use binary numbers, but they are lengthy and unwieldy for humans. Expressing binary numbers as octal and hexadecimal numbers are easier for humans to deal with (this will be demonstrated later). Once the lessons on Numbering Systems Conversions are complete, we will explore tips and tricks for converting between the various number systems. 


Decimal  numbers use a base-10 number system; consisting of digits 0 thru 9.


Octal numbers use a base-8 number system; consisting of digits 0 thru 7.


Hexadecimal numbers use a base-16 number system; consisting of digits 0 thru 9 and letters A thru F.

A = 10, B=11, C=12, D=13, E=14 and F=15


Binary numbers use a base-2 number system; consisting of digits 0 and 1.




Examples: #


The various numbering systems are different ways of counting objects or assigning a value to objects.


If a student had 5 golden stars ( * * * * * ) in decimal we would say there are five (5) stars, in octal and hexadecimal we would say the same.  In binary, the five asterisks would be represented by the number 101.


Another example, let's look at a quantity of twelve objects.  Obviously, in decimal twelve objects would be represented by the number 1210, in octal it would be 148, in hexadecimal it would be C16, and in binary 11002.  


Notice the subscript: it signifies the number's base (or radix). The subscript is only used when there may be ambiguity about the value of the number.  For instance, the number 101.  Without context it could be anything; binary, octal, decimal, or hexadecimal.


Radix (r): Binary (r=2); Octal (r=8); Decimal (r=10); Hexadecimal (r=16)


 

A very common example of assigning binary values to objects are ASCII (American Std Codes for Info Interchange) codes. The student can visit asciitable.com to see an ASCII table that contains the most common character set. Check the table header, it starts with decimal, followed by hex, then octal representations for each of the character in the table. Later, an ASCII table can be used to practice conversing between the different number systems.


For the character '5', we see the decimal, hex and octal values are 5310, 3516, and 0658. As will be shown later, the binary value assigned to the character '5' is 0011 01012.

Trivia: why 4 bits? ... it so happens that hexadecimal digits line up nicely with 4 bits. Hexadecimal also lines up with bytes of information; i.e., 1 byte = 8-bits. Bytes are the fundamental unit of measurement for data in computers, next to bits.  

Because binary numbers are so difficult to record and read, users will often put spaces every 4th bit starting from the right moving left-ward.  E.g., 000111101011 might be written as 0001 1110 1011. Be cautious of your teacher's/professor's preference on assignments, quizzes and exams.  




Example of assigning binary values to objects, we will look at 'System Design Assurance (SDA)' which is a 2-bit data field transmitted by aircraft in the ADS-B OUT messages (if you don't know, google it).  It is defined as follows:


Lesson note: Let's start by providing the definition of a 'bit'. 'bit' comes from the words (b)inary dig(it). 


Note about SDA (not lesson critical): it is defined as the 'probability of an undetected fault causing transmission of False or Misleading Information'.  ADS-B messages contain info about the aircraft's position, velocity and integrity.  The SDA parameter gives the user (ATC, nearby aircraft, ground stations, etc) info about the integrity of the system design. A complicated process involving DO-178 (Software Design Assurance), DO-254 (Hardware Design Assurance) and system safety engineering.  To get a flavor for the other info provided by aircraft via ADS-B messages, visit adsbexchange.com.  



Assignments:


SDA

 0 0 ==>     SDA = 0, means probability is > 10-3 per flight hour, or Unknown probability.

 0 1 ==>     SDA = 1, means probability is < 10-3 per flight hour

 1 0 ==>     SDA = 2, means probability is < 10-5 per flight hour

 1 1 ==>     SDA = 3, means probability is < 10-7 per flight hour



Logic Systems /

Boolean Algebra


Definitions: #

Start by defining the boolean algebraic functions (Logic functions or operators), (i) AND, (ii) OR, and (iii) NOT.

AND - true if all inputs are true and, false if one or more inputs are false.


OR - true if one or more inputs are true and, false if all inputs are false.


NOT - true if input is false and, false if the input is true



Truth Tables: #

A Truth Table is a table that defines the outputs of a logic function for all possible input combinations.  Sometimes a truth table will have more than one output defined.

AND Function Truth Table

A B F
0 0 0
0 1 0
1 0 0
1 1 1


where F = A AND B,  or  A * B or A · B

OR Function Truth Table

A B F
0 0 0
0 1 1
1 0 1
1 1 1


where F = A OR B,  or  A + B

NOT Function Truth Table

A F
0 1
1 0


where F = NOT A,  or  A


In boolean algebra, we use a center dot (or asterisk *; sometimes no operator) to represent the AND operation; similar to the multiplication in algebra. For the OR operator we use the plus sign (+); similar to addition in algebra.  

A message to mathematicians: #


... and/or anyone that has taken/studied Discrete Mathematics:  I am sorry.


For the others, let me explain.  In discrete mathematics, the AND function is called Union and its operator is ∪, and the OR function is called the Intersection and the operator is ∩. Engineers and technologists need to type boolean algebraic equations in CAD tools; CAD tools generally use text editors (basic ASCII character set). Some clever designer discovered that the OR function in boolean algebra (discrete mathematics) behaves a lot like the addition function, and the AND function looks quite a lot like multiplication. 


Good news: regardless of the notation used the processes, functions and results are the same.



Boolean Functions: #


An example of a boolean function is F = A*B + B*C*D, this function has 4 inputs (A, B, C & D) and one output (F).  It can be implemented with one 2-input OR gate, one 2-input AND gate, one 3-input AND gate and one inverter (gate that performs NOT function). Gates and circuit implementations will be discussed in later modules, but it may still be apparent, to the reader, from the equation how to implement the function (that too will be discussed later). 

A word about notation:


  • As with 'discrete' mathematics, when hand-writing boolean algebraic equations, the user can omit the asterisks (note: this does not apply when typing in a text editor for a CAD tool); beware, it is easy to understand intent with the logic expression A*B, but AB could be A AND B, or it could represent a variable AB. Avoid ambiguities; life if confusing enough without generating more confusion.


  • Inverter notation: the NOT function, if hand-written (or in editors with advanced graphics), is represented by an over-bar (e.g., X NOT is X).  The over-bar is not possible in text editors, so the tech community adopted the use of the explanation mark (!); not sure of the origin, but it is also used in the c programming language to mean invert the result (TRUE become FALSE, etc.).  Thus, !x is equivalent to x.


Boolean algebra can be used to reduce/optimize the logic functions.  Reduction and optimization are used to reduce the number of logic gates and/or routing real-estate on PCB's or FPGA's; i.e., basically, boolean algebra can be used to manipulate the logic function into any form the user desires. Learning how to reduce equations is less important today than it was when logic systems design was in its infancy. Logic functions were implemented on discrete chips where the number of gates on a chip was limited. However, the importance of learning the theorems, postulates and how to manipulate them, increases as the reader/student moves into more advanced areas of study; e.g., Masters or PhD degrees in Computer Science, Computer Engineering and Electrical Engineering. These disciplines may need to create or code algorithms used in CAD programs or other places where reducing the logic (boolean) equations to its smallest implementation or useful form of the equation. If the reader would like to study the theorems, click here or just go to the next module.


Deriving Logic: #

Regardless of whether you spend a lot of time memorizing the theorems, there are some intuitive theorems the reader can easily tease out of the truth tables.  (For things you can derive, do not memorize ... derive instead.)

Form 1: using the definition of AND/OR: #


Recall the definition of, 

  • AND: true if all the inputs are true, and false if any one input is false, and 
  • OR: true if any one input is true, and false if all inputs are false


  • With these definition, the user can derive the truth table of any x-input AND and OR gates.  Here is an example of a 3-input AND gate and of a 3-input OR gate. F1 = A B C, and F2 = A + B + C, :


A B C F1 F2
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 0 1
1 0 0 0 1
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1


If the reader sees the collection of inputs on each row as a binary number, they will realize that setting up a truth table is just a matter of counting from 0 to 2n-1. From the table we see 000, 001, 010, 011, 100, 101, 110 and 111... which, in decimal, are 0, 1, 2, 3, 4, 5, 6 and 7, respectively.


Soon the author will introduce the concept of Minterms and Maxterms.  For Minterms/Maxterms, the number order of inputs is important in defining the functions.



Form 2: using the definition of AND/OR:


Axioms: fairly easy to see from the definitions:

0 · 0 = 0

1 · 1 = 1

1 · 0 = 0 · 1 = 0


0 + 0 = 0

1 + 1 = 1

1 + 0 = 0 + 1 = 1

if x = 0, then x = 1

if y = 1, then y = 0


Single-variable theorems:


  • Example derivations for single-var theorems: if presented with the case where 0 AND'd with a variable X (0·X), then the user can use the definition of AND to determine 0·X is always false (0).  So, we have the first postulate: 0 · X = 0.


X · 0 = 0 when X=0, X·0 = 0; when X=1, X·0 = 0 'anything AND'd with a zero is always zero'
X · 1 = X when X=0, X·1 = 0; when X=1, X·1 = 1 'anything AND'd with a one is itself'
X + 0 = X when X=0, X+0 = 0; when X = 1, X+0 = 1 'anything OR'd with a zero is itself'
X + 1 = 1 when X=0, X+1 = 1; when X=0, X+1 = 1 'anything OR'd with a one is one'
X · X = X when X=0, X·X = 0; when X=1, X·X = 1 'anything AND'd with itself is itself'
X + X = X when X=0, X+X = 0; when X=1, X+X = 1 'anything OR'd with itself is itself'
X · X = 0 when X=0, X·X = 0; when X=1, X·X = 0 'anything AND'd with its complement is zero'
X + X = 1 when X=0, X+X = 1; when X=1, X+X = 1 'anything OR'd with its complement is one'


  • An example of where these theorems would be handy: assume a case where an arbitrary, single, product-term (x · z) in the function, f with 3-inputs (x, y & z) {we would write f(x,y,z) = x · z }  If the user desires an expression where each product-term contains all inputs, then the equation f(x,y,z) needs to be manipulated to achieve that goal.  We know that y + y = 1 and s · 1 = s, we can extend these theorems to our situation as, 


f(x,y,z) = (x · z) · (1)


f(x,y,z) = (x·z) · (y + y) , by substitution


f(x,y,z) = (x·y·z) + (x y z), by using distributive property



Logic Systems /

Implement Logic Equations

<<Reserved>>
Logic Systems /

Optimization

<<Reserved>>
Logic Systems /

MSI Circuits

<<Reserved>>
Logic Systems /

Arithmetic Processing

<<Reserved>>
Logic Systems /

Intro - Sequential Logic

<<Reserved>>
Logic Systems /

Latches and Flip-Flops

<<Reserved>>
Logic Systems /

Timing Diagrams

<<Reserved>>
Logic Systems /

Finite State Machines

<<Reserved>>
Logic Systems /

FSM Controllers

<<Reserved>>
Logic Systems /

High-Level State Diagram

<<Reserved>>
Logic Systems / Digital Data /

Formal Definition: Numbering Systems


Formal Numbering System Definition #


A number N can be represented by the following equation:


N = ∑ (di ∙ ri), where i = 0 to (n-1)


n = number of digits in N,


The variable i starts at zero and increases by 1 up to (n-1), for now we will deal with i being positive. 
Note: this equation works with negative values for i . When i is negative, the number N is between 0 and 1 ... in short, small numbers.  For digital systems, we have much more efficient ways of handing small numbers, called floating point numbers. (discussed later).


Speaking of negative numbers ... in digital systems there are several ways of handling a negative N value.  This topic will be developed later, as well.  For now, be happy with positive integers. As you will see, they can be quite useful a by themselves.


Position and Weight: #


Position is represented by a number starting at position 0 on the right and moving toward the left to position (n-1) (n = number of digits).  Each digit in the number has a
position number.  E.g., for the number 2468, the digit in position 0 is '8' and position 3 is '2', etc.

Weight is the multiplier for the
position. The weight is the ri portion of the above equation.  From previous example, let's assume 2468 is a decimal number, this means r = 10.  Thus, the weight of the 2nd position is 102 = 100; weight of position 0 is 1.


Sidebar: Zero (0)


In the digital domain, we categorize zero (0) as a positive integer ...


... zero is also considered an even number, but we will discuss that later (wait for XOR gates & Parity).


From the equation above, the variable r represents the radix of the number N.  

r is 2 for binary, 8 for octal, 10 for decimal, and 16 for hexadecimal.


From the equation above, the variable di represents the digit of the number N starting with i = 0 for the least significant digit, here is an example using the decimal number 48,519:

The position values for 48,519 are,  d= 9, d= 1, d= 5, d= 8, and d= 4. And, the number of digits (n) is 5.


N    = d4∙104 + d3∙103 + d2∙102 + d1∙101 + d0∙100
N    = 4∙104 + 8∙103 + 5∙102 + 1∙101 + 9∙100
N    = 4∙10,000 + 8∙1,000 + 5∙100 + 1∙10 + 9∙1
N    = 48,519


The process is the same for other numbering systems.  Let's take a hexadecimal number and decompose it; try BA23D16 (BTW: there are other ways of indicating a number is hex.  Here is a couple, (i) 0xBA23D, or (ii) BA23Dh.

N    = d4∙164 + d3∙163 + d2∙162 + d1∙161 + d0∙160
N    = B∙164 + A∙163 + 2∙162 + 3∙161 + D∙160
N    = 11∙65,636 + 10∙4,096 + 2∙256 + 3∙16 + 13∙1
N    = 762,429 <== decimal
Projects / Linux Specific / Linux Basics / Secure Shell /

Secure Auto-Login


SSH Key Generation: #


In order to allow automatic login, crypto keys must be generated.  The following steps should be followed:

cd ~/.ssh 


Type ssh-keygen;     

<<NOTE: leave passphrase blank, both times!>>

<<Also, note the file_name where the key is stored>>


Now take a look the ./.ssh folder to see that the <file_name.pub> key file is present.  ls -alF


ssh-copy-id   -i   <~/.ssh/file_name.pub>  <remote_user_name@remote_host> 




Projects / Linux Specific / Linux Basics /

Secure Shell


Terminal cmd-line: ssh <remote_user_name>@<remoteHost>

Example,  ssh pi@192.168.1.3 opens a remote secure shell (terminal) on 192.168.1.3, with a user_name of 'pi' on the computer whose IP address is 192.168.1.3.


Auto-login:  if the account requires a password in order to login, you will need to generate keys.  This might be necessary when you want to use crontab (for instance) to update software on remote computers, or periodically copy files from a remote computer.


With ssh the operator can manipulate the remote computer as if operating the cmd-line terminal from that computer.





Projects / Serial Comms / GPS unit (BU-353S4) /

gpsd: GPS daemon


Couple methods to disable the gpsd daemon:

sudo start-stop-daemon -K --name gpsd


sudo systemctl stop gpsd.socket

sudo systemctl disable gpsd.socket

<<WIP - more to come>>

Projects / Linux Specific / Linux Basics /

Setup File Server


These steps can be used to setup a Samba File Server:

Original goal was to use a Raspberry Pi 4 to implement a DLNA Media Server.  MiniDLNA is a media server is simple. The over-arching design requirement for a Media Server was for 'robust recovery from power glitch'.


These steps should work for any computer with a Linux OS.


Assumptions:

storage device mount points will be in /media/share/

  • Ensure computer is up-to-date; sudo apt update; sudo apt upgrade


  • Install Samba File Sharing service; sudo apt install samba


  • Create folder as mounting point for new share; in this case, we are putting all of our shares in /media/share/; mkdir /media/share/share-01


  • Give all permissions to the shares folder; sudo chmod 777 /media/share/share-01


  •  Give ownership to 'nobody:nogroup' (required for miniDLNA);  sudo chown -R nobody:nogroup /media/share/share-01


  • Edit /etc/samba/smb.conf and add the following:
[shareDrive-01]

     comment = RaspberryPi

     browsable = yes

     read only = no

     guest ok = yes

     guest only = yes

     path = /media/share/share-01

     create mask = 777

     directory mask = 777


  • Other computers will see the drive as shareDrive-01


  • Repeat these steps for each drive connected to the file server



Install miniDLNA: #



Logic Systems / Digital Data /

Number Conversions

The last example from 'Formal Definition: Numbering systems', we demonstrated the conversion of a hexadecimal number to decimal. Here we will demonstrate how to convert from the various types of numbers.


Binary Notes: let's start with the reason we are here ... to understand the language of digital systems, binary numbers.  Machines operate at a fundamental level based on switches.  Tiny devices called transistors are either ON (1) or OFF (0).  So, information from a digital system is binary nature.  Based on the relationship between operator and machine, we are required to interrupt the data in order to communicate. 

Converting Binary to Decimal ('add weight of ones'): #


  • Illustrate by example, assume N = 10110 is a binary number.  Find the value of N in decimal form.
Solution:


  1. From the equation in previous module,
    N =  1*104  +  0*103 +   1*102 +   1*101 +  0*100
         =  1*16   +   0*8    +    1*4    +     1*2   +    0*1
         =    16     +     0      +       4     +        2     +      0
         =     2210

  2. Notice from the previous method that the total is only impacted where the ones (1) are located. The positions where the digit (or bit) is a zero (0) the weight is multiplied by zero, resulting in no contribution to the total.

    So, add the weight of the bit positions that have a value of one (1). (I always think to my self, 'add the weight of the ones'.)

Steps (Process):

a) start from right-most bit, its positional weight is 1; moving to the left, the weight of the next bit is 2; then 4; then 8; ...<<multiply by 2 each move left ... divide by 2 if moving right>>... 16; 32; 64; 128; 256; 512; 1,024; 2,048; 4,096; 8,192; 16,384; 32,768; 65,536; etc.


b) for N = 10110, litany goes "1 ... (add that) ... (add that) ... 8 ... 16 (add) ... 2 + 4 + 16 = 22".  Recommend writing out the binary number and annotating the weight you want to add under each of the ones. 


 1    0    1    1    0

 16            8             4             2             1

16                            4              2                 ----> 'add the weight of the ones' ----> 22 (decimal)


Converting Decimal to Binary: #


  • There are no tricks for this type conversion, just two brute force methods,
(1) subtraction method, and (2) division method.


We are going to leave it as an exercise for the student to seek out the division method if he/she are unsatisfied with the subtraction method.


Process:

  1. Find the largest binary positional weight that can be subtracted without causing the result to be negative;
  2. Subtract it and put a one in that position; keep the remaining amount;
  3. From the remaining amount subtract the largest binary positional weight without causing a negative remainder;
  4. Repeat until remaining amount is equal zero;
  5. Fill in the remaining bit positions with zeros and you have the result.


Example 1, For a decimal number N = 42, find the binary equivalent: 

  • 1, 2, 4, 8, 6, 32, 64 ... 64 is too large, so start with 32 ... 42 - 32 = 10, (note: 32 is 25, 6th position from the right);
  • 10 - 8 = 2 ... 8 is 23 (4th position);
  • 2 - 2  = 0 ... 2 is the 2nd position.
  • Solution: 1(6th); 1(4th); 1(2nd); zeros elsewhere, ==> N = 1010102.


Example 2, For the decimal number N = 841, find the binary equivalent,:

  • 841 - 512 = 329; 512 = 29  (pos. 10);
  • 329 - 256 = 73;  256 = 28 (pos. 9);
  • 73 - 64 = 9; 64 = 25 (pos. 7);
  • 9 - 8 = 1; 8 = 23 (pos. 4); and
  • 1 - 1 = 0; 1 = 20 (pos. 1).
  • Solution: 11010010012



Converting Hexadecimal to Binary (and Bin to Hex): #


  • Each hexadecimal digit has 16 possible values;  which is coincidentally the same number of possible values for 4-bit binary numbers.  

  • Either replace the hexadecimal digit with the equivalent 4-bit binary value, or replace 4-bits binary data with one hexadecimal digit.

An exercise,

Let's assign a binary value to each hexadecimal digit:


No. Binary Hex
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F


If you work with converting binary to hex, and hex to binary on a regular basis, this table will become route.  However, if memorization is needed then here are a couple of tips:

  • 1000 is eight. It helps to remember 8 4 2 1; these are the bit positional weights, in order.  If you know this pattern you know the values of 1000, 0100, 0010, and 0001.
  • Memorize 1100(bin) ... It is Ch or 0xC ... One more is D, which is 13 or 1101.  Subtract one (1) from 1100 - 1 = 1011 or Bh or 11 (dec).

Example, for the hex number, 0xba23d, find the binary equivalent:

Solution: b = 1011; a = 1010; 2 = 0010; 3 = 0011; d = 1101 ... concatenate the 4-bit binary values to get the result ==> 101110100010001111012.

A conversion of 0xba23d to decimal was already illustrated in the previous module.  So, let's double check by converting the binary result above to decimal and compare to result from previous module.  

  • 'Add the weight of the ones' --> SUM(weight of ones), 
  • {starting from the right for 10111010001000111101}, 
  • SUM(1, 4, 8, 16, 32, 512, 8192, 32768, 65536, 131072, 524288) ... 762,429 (checks out).


Another example, for the binary number 101100111110110, find the hexadecimal equivalent.

Solution:  sub-divide binary word into 4-bit chunks, starting from right; 101--1001--1111--0110 ... pad out last 4-bit portion, if necessary.  In this case it is necessary, or maybe you can already see it is a 5 without adding the zero (0) {0101).  Thus, we have 5--9-F--6 .. so, the result is 0x59F6.



Note: hexadecimal is used as a short-hand method of noting binary values, especially large binary values (16-bit, or higher, systems.)  Would you rather say or write, "one, zero, one, one, one, zero, one, zero, zero, zero, one, zero, zero, zero, one, one, one, one, zero, one", OR "b, a, 2, 3, d".


<<give example of what a captured 1553 message looks like>>


Converting Octal to Binary (and Bin to Oct): #


  • Each octal digit has 8 possible values;  which is coincidentally the same number of possible values for 3-bit binary numbers.  

  • Either replace the octal digit with the equivalent 3-bit binary value, or replace 3-bits binary data with one octal digit.
Converting binary to/from octal is the same concepts as converting binary to/from hexadecimal.  


Octal is much less common.  Unlike hexadecimal, octal numbers do not have boundaries that coincide with boundaries on bytes; so use of octal numbers in computer applications is limited, however, it has other applications.

Sidebar: One place that octal is still used is in air traffic control surveillance application.  When ATC tells the aircraft to SQUAWK 4371, or similar, they are giving the pilot of the aircraft a 4-digit octal number.  The pilot changes the value on his transponder and then the blip on the ATC operator screen is labeled with 4371.  If the pilot was in an emergency situation, he would dial 7700 into his transponder and ATC would get immediate alarms on his display.  BTW, already on a tangent so may as well go all in; some other codes 7500 - hi-jack in progress; 7600 - no radio (NORDO).


Exercise, convert the binary number 1110110001000 to octal and hexadecimal.

Solution:  Octal: divide into threes: 1-110-110-001-000 --> 001  110  110  001  000 --> 16610 (oct).  Hexadecimal: 1101-1000-1000 --> D88h




Projects / Linux Specific / Raspberry Pi /

Pico

Raspberry Pi Pico Jumping off point ... #




New project idea, check out "Jeff probe" on Amazon ... also, look up Black Magic Probe


RP2040 microcontroller by Raspberry Pi dual-core Arm Cortex-M0+ processor with 264kB internal RAM and support for up to 16MB of off-chip flash. A wide range of flexible I/O options includes I2C, SPI, and - uniquely - Programmable I/O (PIO)


Micropython quick ref


Python tutorial


Micropython Interrupt Service Routine (ISR) handler



Logic Systems / Boolean Algebra /

Discrete Theorems and Postulates

Theorems and Postulates: 


A = A * 1; 1 = A + 1

0 = A * 0; A = A + 0


DeMorgan's Theorem: F = 

(Note: break the line, change the sign.)


Projects /

Serial Comms

No Page Content
Projects / Serial Comms /

IIC I2C Comms

  • Inter-Integrated Circuit (IIC or I2C), similar to SPI

  • Multiple masters are allowed; Master controls data flow

  • Data transfer is synchronous

  • SDA - Serial Data signal; Master and Slave SDA connected;
  • SCL - Serial data Clock; master and slive SLC connected, output only for Master;

  • Speed Modes: (i) Standard mode: 100kbps, (ii) Fast mode: 400kbps, (III) High-speed: 3.4Mbps, and (iv) Ultra-fast mode: 5Mbps.

  • Data is valid on the SDA line when falling-edge of SCL (clock)

  • R/W - indicates when the slave Reads or is expected to Write data during the current frame.  RW=0 means Slave Reads from SDA, and RW=1 means Slave Writes to SDA.


Projects / Linux Specific /

Virtual machines [w-i-p]

Virtual Machines #

  • Options VMware or Oracle's VitrualBox (vbox)
    • Oracle's VM manager is free and free is good;

  • Virtual machines (VM) allow the end user to operate a separate, sequestered operating system (OS)

    • I use mine to run older CAD software that will not run on my current OS;
    • There are many uses, in a nutshell it allows the user to sandbox the OS ... 
    • Perhaps solving the problem of a pesky application that does not play well with others;
    • or, alternatively, can start using Linux and keep a Windows VM for 'the things that only Windows can do'

  • Whichever VM architecture you choose, 

    • the end user will need a VM manager, 

    • this page will guide the user with my notes on installation


Vbox Setup

  • Start by ensuring system up-to-date (sudo apt update;sudo apt upgrade -y)


  • For Kubuntu, install from the Discover, software center;
    • If your distro is different, use the appropriate software center or google how to do it from the command-line.


  • Setup requires an ISO of the operating system to be the basis of the VM,


  • Use the default settings to get started, then progress to tweaking until you get the performance you need. Google or some other NPU assistance will help you get further.
this is the end ... the end my friend ... not really! Other notes may be coming ...