All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Signed-off-by: Severin Kaderli <severin@kaderli.dev>
38 lines
1,016 B
Python
38 lines
1,016 B
Python
// 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)
|
|
|
|
while transmission_not_stopped:
|
|
// 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
|
|
for code_bit in encoded_packet:
|
|
if code_bit is 1:
|
|
stress_cpu(clock_speed)
|
|
else:
|
|
idle_cpu(clock_speed)
|