Skip to content

Commit

Permalink
ESP pipeline fixes (#1588)
Browse files Browse the repository at this point in the history
* Update arduino-esp.yml for Azure Pipelines

* Update esp_arduino_uart_interface.py

* Update serial_connect.py

* Delete mxchip_settings.py

* try save env variable

* ok ok ok

* Update azure_test_firmware_errors.py
  • Loading branch information
jbobotek authored Jul 18, 2020
1 parent b57f259 commit 258b27a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 4 additions & 0 deletions build/arduino-esp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
echo -e "exit\r\n\r\n\r\n" | cat > input.txt
python3 serial_connect.py -i input.txt -o output.txt -b 115200 -p $(ESP8266_PORT) -d esp8266 -s
rm input.txt
code=$(<exitcode.txt)
exit $code
failOnStderr: true
displayName: 'run_test'
Expand Down Expand Up @@ -96,6 +98,8 @@ jobs:
echo -e "exit\r\n\r\n\r\n" | cat > input.txt
python3 serial_connect.py -i input.txt -o output.txt -b 1000000 -p $(ESP32_PORT) -d esp32 -s
rm input.txt
code=$(<exitcode.txt)
exit $code
failOnStderr: true
displayName: 'run_test'
Expand Down
2 changes: 1 addition & 1 deletion testtools/UART_interface/azure_test_firmware_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
wifi_failure = "AZ001"
iot_init_failure = "AZ002"
sensor_init_failure = "AZ003"
SDK_ERRORS = 0
SDK_ERRORS = 0
15 changes: 8 additions & 7 deletions testtools/UART_interface/esp_arduino_uart_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import time
try:
from testtools.UART_interface.base_uart_interface import uart_interface
except:
from base_uart_interface import uart_interface

try:
import testtools.UART_interface.azure_test_firmware_errors as azure_test_firmware_errors
import testtools.UART_interface.serial_settings as serial_settings
import testtools.UART_interface.serial_commands_dict as commands_dict
except:
import azure_test_firmware_errors
import serial_settings
import serial_commands_dict as commands_dict
from base_uart_interface import uart_interface


# ------- global usecase fcns -------
Expand All @@ -24,10 +21,13 @@ def check_sdk_errors(line):
local_line = line.lower()
if "error" in local_line or "fail" in local_line:
if "epoch time failed!" in local_line: # don't count NTP retries.
pass
azure_test_firmware_errors.SDK_ERRORS += 0
else:
azure_test_firmware_errors.SDK_ERRORS += 1

# missing test_failures method, may not need due to this being a sample,
# not a series of tests

def check_firmware_errors(line):
if azure_test_firmware_errors.iot_init_failure in line:
print("Failed to connect to saved IoT Hub!")
Expand Down Expand Up @@ -117,7 +117,6 @@ def serial_read(self, ser, message, file, first_read=False):
except:
return None

# Note: the buffer size on the mxchip appears to be 128 Bytes.
def write_read(self, ser, input_file, output_file):
if 'esp32' in serial_settings.device_type:
serial_settings.bits_to_cache = 800
Expand Down Expand Up @@ -160,5 +159,7 @@ def write_read(self, ser, input_file, output_file):

# forward failed callbacks to SDK_ERRORS
azure_test_firmware_errors.SDK_ERRORS += self.messages_sent - self.message_callbacks
with open('exitcode.txt', 'w') as fexit:
fexit.write('%d' %azure_test_firmware_errors.SDK_ERRORS)

output_file_obj.close()
output_file_obj.close()
Empty file.
2 changes: 1 addition & 1 deletion testtools/UART_interface/mxchip_uart_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def check_firmware_errors(line):

# ------- interface class -------
class mxchip_uart_interface(uart_interface):

# Note: commands on MXCHIP have line endings with \r AND \n
# If there is a sudden disconnect, program should report line in input script reached, and close files.
# method to write to serial line with connection monitoring
def serial_write(self, ser, message, file=None):
Expand Down
13 changes: 4 additions & 9 deletions testtools/UART_interface/serial_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import mxchip_uart_interface
import esp_arduino_uart_interface

# Note: commands on MXCHIP have line endings with \r AND \n
# Notes: This is designed to be used as a command line script with args (for automation purposes) to communicate over serial to a Microsoft mxchip device.
# Note: This collection of scripts is designed to be used as a command line script with args (for automation purposes)
# to communicate over serial to Azure IoT C SDK supported devices.

uart = None

Expand All @@ -28,7 +28,6 @@ def usage():
usage_txt = "serial_connect.py usage: \r\n"
for commands in commands_dict.cmds:
usage_txt += " - %s: " %commands + commands_dict.cmds[commands]['text'] + "\r\n"

return usage_txt

def parse_opts():
Expand Down Expand Up @@ -75,8 +74,7 @@ def check_firmware_errors(line):
azure_test_firmware_errors.SDK_ERRORS += 1


# If there is a sudden disconnect, program should report line in input script reached, and close files.
# method to write to serial line with connection monitoring
# Method to write to serial line with connection monitoring
def serial_write(ser, message, file=None):

# Check that the device is no longer sending bytes
Expand Down Expand Up @@ -178,13 +176,10 @@ def run():
if len(output) > 4:
print(output)

if 'rpi' in serial_settings.device_type or 'raspi' in serial_settings.device_type:
# for rpi, transfer pipeline/artifact files from agent to device
# get filepath, walk it
# for each file, send rz, then sz file to rpi port



if 'rpi' in serial_settings.device_type or 'raspi' in serial_settings.device_type:
uart = rpi_uart_interface.rpi_uart_interface()
elif 'mxchip' in serial_settings.device_type:
uart = mxchip_uart_interface.mxchip_uart_interface()
Expand Down

0 comments on commit 258b27a

Please sign in to comment.