Finalize thesis report and fix grammar mistakes
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
parent
77fbdd194f
commit
10bf9ebf44
21 changed files with 2716 additions and 211 deletions
41
documentation/thesis/listings/receiving_pseudo.py
Normal file
41
documentation/thesis/listings/receiving_pseudo.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Define constants
|
||||
preamble = [1, 1, 1, 0, 0, 0, 1, 1, 1]
|
||||
|
||||
// Get sensor values
|
||||
sensor_values = get_data_from_sensor()
|
||||
|
||||
value_range = range_of_data(sensor_values)
|
||||
|
||||
// Determine for sensor values if they are a high or low signal
|
||||
signal = []
|
||||
for value in sensor_values:
|
||||
// Compare the value with the median of the values with some threshold
|
||||
if value < median_with_threshold(value_range):
|
||||
signal += low
|
||||
else if value > median_with_threshold(value_range):
|
||||
signal += high
|
||||
else:
|
||||
// Discard value
|
||||
|
||||
// Filter out single high or low signals
|
||||
signal = clean_signal(signal)
|
||||
|
||||
// Only keep the first of consecutive same signals, as the transitions hold the data
|
||||
signal = compress_signal(signal)
|
||||
|
||||
// Check for preamble in data
|
||||
if contains(signal, preamble):
|
||||
// Decode the received manchester encoded bitstream
|
||||
packet = signal[index(preamble)]
|
||||
|
||||
// Read the first four bits of the bitstream to get the header
|
||||
header = read_bits(packet, 0, 4)
|
||||
display_header(header)
|
||||
|
||||
// Read the next n Bytes of the bitstream, according to the payload length, to get the payload
|
||||
payload = read_bits(packet, 4, header)
|
||||
display_payload(payload)
|
||||
|
||||
// Read the next byte to get the CRC-8-AUTOSAR checksum of the payload
|
||||
checksum = read_bits(packet, 4 + header, 8)
|
||||
show_checksum_result()
|
38
documentation/thesis/listings/sending_pseudo.py
Normal file
38
documentation/thesis/listings/sending_pseudo.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Define constants
|
||||
preamble = [1, 1, 1, 0, 0, 0, 1, 1, 1]
|
||||
|
||||
// Set clock speed
|
||||
clock_speed = 500
|
||||
|
||||
// Get the text from the user
|
||||
text = get_input()
|
||||
|
||||
// Convert the ASCII text to a bit stream
|
||||
payload = ascii_to_bits(text)
|
||||
|
||||
// Calculate the length of the payload in bytes
|
||||
header = byte_length(payload)
|
||||
|
||||
// Calculate the CRC-8-AUTOSAR checksum of the payload
|
||||
checksum = calculate_checksum(payload)
|
||||
|
||||
// Combine the header, payload, and checksum into a packet
|
||||
packet = to_bits(header) + payload + to_bits(checksum)
|
||||
|
||||
// Encode packet using manchester encoding
|
||||
encoded_packet = manchester_encode(packet)
|
||||
|
||||
// Start the transmission by sending the preamble
|
||||
for symbol in preamble:
|
||||
if symbol is 1:
|
||||
stress_cpu(1000)
|
||||
else:
|
||||
idle_cpu(1000)
|
||||
|
||||
// Transmit the manchester encoded bit stream of the packet
|
||||
while transmission_not_stopped:
|
||||
for code_bit in encoded_packet:
|
||||
if code_bit is 1:
|
||||
stress_cpu(clock_speed)
|
||||
else:
|
||||
idle_cpu(clock_speed)
|
Reference in a new issue