mirror of https://github.com/ARMmbed/mbed-os.git
Merge branch 'master' of https://github.com/mbedmicro/mbed
commit
c8ca6c339b
|
@ -51,7 +51,13 @@ public:
|
||||||
* An integer with each bit corresponding to the value read from the associated DigitalIn pin
|
* An integer with each bit corresponding to the value read from the associated DigitalIn pin
|
||||||
*/
|
*/
|
||||||
int read();
|
int read();
|
||||||
|
|
||||||
|
/** Set the input pin mode
|
||||||
|
*
|
||||||
|
* @param mode PullUp, PullDown, PullNone
|
||||||
|
*/
|
||||||
|
void mode(PinMode pull);
|
||||||
|
|
||||||
#ifdef MBED_OPERATORS
|
#ifdef MBED_OPERATORS
|
||||||
/** A shorthand for read()
|
/** A shorthand for read()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -49,6 +49,14 @@ int BusIn::read() {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BusIn::mode(PinMode pull) {
|
||||||
|
for (int i=0; i<16; i++) {
|
||||||
|
if (_pin[i] != 0) {
|
||||||
|
_pin[i]->mode(pull);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MBED_OPERATORS
|
#ifdef MBED_OPERATORS
|
||||||
BusIn::operator int() {
|
BusIn::operator int() {
|
||||||
return read();
|
return read();
|
||||||
|
|
|
@ -18,16 +18,20 @@
|
||||||
static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode)
|
static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode)
|
||||||
{
|
{
|
||||||
gpio_init(gpio, pin);
|
gpio_init(gpio, pin);
|
||||||
gpio_dir(gpio, PIN_INPUT);
|
if (pin != NC) {
|
||||||
gpio_mode(gpio, mode);
|
gpio_dir(gpio, PIN_INPUT);
|
||||||
|
gpio_mode(gpio, mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value)
|
static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value)
|
||||||
{
|
{
|
||||||
gpio_init(gpio, pin);
|
gpio_init(gpio, pin);
|
||||||
gpio_write(gpio, value);
|
if (pin != NC) {
|
||||||
gpio_dir(gpio, PIN_OUTPUT);
|
gpio_write(gpio, value);
|
||||||
gpio_mode(gpio, mode);
|
gpio_dir(gpio, PIN_OUTPUT);
|
||||||
|
gpio_mode(gpio, mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpio_init_in(gpio_t* gpio, PinName pin) {
|
void gpio_init_in(gpio_t* gpio, PinName pin) {
|
||||||
|
@ -49,7 +53,8 @@ void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) {
|
||||||
void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) {
|
void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) {
|
||||||
if (direction == PIN_INPUT) {
|
if (direction == PIN_INPUT) {
|
||||||
_gpio_init_in(gpio, pin, mode);
|
_gpio_init_in(gpio, pin, mode);
|
||||||
gpio_write(gpio, value); // we prepare the value in case it is switched later
|
if (pin != NC)
|
||||||
|
gpio_write(gpio, value); // we prepare the value in case it is switched later
|
||||||
} else {
|
} else {
|
||||||
_gpio_init_out(gpio, pin, mode, value);
|
_gpio_init_out(gpio, pin, mode, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ static const PinMap PinMap_PWM[] = {
|
||||||
{PA_2, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH3
|
{PA_2, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH3
|
||||||
//{PA_2, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH3
|
//{PA_2, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH3
|
||||||
//{PA_2, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH1
|
//{PA_2, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH1
|
||||||
{PA_3, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH3
|
{PA_3, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH4
|
||||||
//{PA_3, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH4
|
//{PA_3, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH4
|
||||||
//{PA_3, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH2
|
//{PA_3, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH2
|
||||||
{PA_5, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH1
|
{PA_5, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH1
|
||||||
|
@ -77,7 +77,7 @@ static const PinMap PinMap_PWM[] = {
|
||||||
{PC_6, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH1
|
{PC_6, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH1
|
||||||
{PC_7, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH2
|
{PC_7, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH2
|
||||||
{PC_8, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH3
|
{PC_8, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH3
|
||||||
{PC_9, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH3
|
{PC_9, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH4
|
||||||
|
|
||||||
{NC, NC, 0}
|
{NC, NC, 0}
|
||||||
};
|
};
|
||||||
|
@ -183,13 +183,13 @@ void pwmout_write(pwmout_t* obj, float value) {
|
||||||
break;
|
break;
|
||||||
// Channels 3
|
// Channels 3
|
||||||
case PA_2:
|
case PA_2:
|
||||||
case PA_3:
|
//case PA_3:
|
||||||
case PA_10:
|
case PA_10:
|
||||||
//case PB_0:
|
//case PB_0:
|
||||||
case PB_8:
|
case PB_8:
|
||||||
case PB_10:
|
case PB_10:
|
||||||
case PC_8:
|
case PC_8:
|
||||||
case PC_9:
|
//case PC_9:
|
||||||
channel = TIM_CHANNEL_3;
|
channel = TIM_CHANNEL_3;
|
||||||
break;
|
break;
|
||||||
// Channels 3N
|
// Channels 3N
|
||||||
|
@ -199,10 +199,11 @@ void pwmout_write(pwmout_t* obj, float value) {
|
||||||
complementary_channel = 1;
|
complementary_channel = 1;
|
||||||
break;
|
break;
|
||||||
// Channels 4
|
// Channels 4
|
||||||
//case PA_3:
|
case PA_3:
|
||||||
case PA_11:
|
case PA_11:
|
||||||
//case PB_1:
|
//case PB_1:
|
||||||
case PB_9:
|
case PB_9:
|
||||||
|
case PC_9:
|
||||||
channel = TIM_CHANNEL_4;
|
channel = TIM_CHANNEL_4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "pinmap.h"
|
#include "pinmap.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
#define RANGE_12BIT (0xFFF)
|
#define DAC_RANGE (0xFFF) // 12 bits
|
||||||
|
|
||||||
static const PinMap PinMap_DAC[] = {
|
static const PinMap PinMap_DAC[] = {
|
||||||
{PA_4, DAC_1, STM_PIN_DATA(GPIO_Mode_AN, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)}, // DAC_OUT1
|
{PA_4, DAC_1, STM_PIN_DATA(GPIO_Mode_AN, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)}, // DAC_OUT1
|
||||||
|
@ -56,7 +56,7 @@ void analogout_init(dac_t *obj, PinName pin) {
|
||||||
// Configure GPIO
|
// Configure GPIO
|
||||||
pinmap_pinout(pin, PinMap_DAC);
|
pinmap_pinout(pin, PinMap_DAC);
|
||||||
|
|
||||||
// Save the channel for the write and read functions
|
// Save the channel for future use
|
||||||
obj->channel = pin;
|
obj->channel = pin;
|
||||||
|
|
||||||
// Enable DAC clock
|
// Enable DAC clock
|
||||||
|
@ -71,6 +71,12 @@ void analogout_init(dac_t *obj, PinName pin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void analogout_free(dac_t *obj) {
|
void analogout_free(dac_t *obj) {
|
||||||
|
DAC_TypeDef *dac = (DAC_TypeDef *)(obj->dac);
|
||||||
|
// Disable DAC
|
||||||
|
DAC_DeInit(dac);
|
||||||
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, DISABLE);
|
||||||
|
// Configure GPIO
|
||||||
|
pin_function(obj->channel, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dac_write(dac_t *obj, uint16_t value) {
|
static inline void dac_write(dac_t *obj, uint16_t value) {
|
||||||
|
@ -87,15 +93,15 @@ void analogout_write(dac_t *obj, float value) {
|
||||||
if (value < 0.0f) {
|
if (value < 0.0f) {
|
||||||
dac_write(obj, 0); // Min value
|
dac_write(obj, 0); // Min value
|
||||||
} else if (value > 1.0f) {
|
} else if (value > 1.0f) {
|
||||||
dac_write(obj, (uint16_t)RANGE_12BIT); // Max value
|
dac_write(obj, (uint16_t)DAC_RANGE); // Max value
|
||||||
} else {
|
} else {
|
||||||
dac_write(obj, (uint16_t)(value * (float)RANGE_12BIT));
|
dac_write(obj, (uint16_t)(value * (float)DAC_RANGE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void analogout_write_u16(dac_t *obj, uint16_t value) {
|
void analogout_write_u16(dac_t *obj, uint16_t value) {
|
||||||
if (value > (uint16_t)RANGE_12BIT) {
|
if (value > (uint16_t)DAC_RANGE) {
|
||||||
dac_write(obj, (uint16_t)RANGE_12BIT); // Max value
|
dac_write(obj, (uint16_t)DAC_RANGE); // Max value
|
||||||
} else {
|
} else {
|
||||||
dac_write(obj, value);
|
dac_write(obj, value);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +109,7 @@ void analogout_write_u16(dac_t *obj, uint16_t value) {
|
||||||
|
|
||||||
float analogout_read(dac_t *obj) {
|
float analogout_read(dac_t *obj) {
|
||||||
uint32_t value = dac_read(obj);
|
uint32_t value = dac_read(obj);
|
||||||
return (float)value * (1.0f / (float)RANGE_12BIT);
|
return (float)((float)value * (1.0f / (float)DAC_RANGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t analogout_read_u16(dac_t *obj) {
|
uint16_t analogout_read_u16(dac_t *obj) {
|
||||||
|
|
|
@ -1,28 +1,46 @@
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
#include "MMA8451Q.h"
|
#include "MMA8451Q.h"
|
||||||
|
#include "test_env.h"
|
||||||
#define MMA8451_I2C_ADDRESS (0x1d<<1)
|
|
||||||
|
|
||||||
#ifdef TARGET_KL05Z
|
#ifdef TARGET_KL05Z
|
||||||
#define SDA PTB4
|
#define SDA PTB4
|
||||||
#define SCL PTB3
|
#define SCL PTB3
|
||||||
#else
|
#else
|
||||||
#define SDA PTE25
|
#define SDA PTE25
|
||||||
#define SCL PTE24
|
#define SCL PTE24
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const int MMA8451_I2C_ADDRESS = 0x1D << 1; // I2C bus address
|
||||||
|
const float MMA8451_DIGITAL_SENSITIVITY = 4096.0; // Counts/g
|
||||||
|
}
|
||||||
|
|
||||||
|
float calc_3d_vector_len(float x, float y, float z) {
|
||||||
|
return sqrt(x*x + y*y + z*z);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TEST_ITERATIONS 25
|
||||||
|
#define TEST_ITERATIONS_SKIP 5
|
||||||
|
#define MEASURE_DEVIATION_TOLERANCE 0.025 // 2.5%
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
DigitalOut led(LED_GREEN);
|
DigitalOut led(LED_GREEN);
|
||||||
MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
|
MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
|
||||||
printf("WHO AM I: 0x%2X\r\n", acc.getWhoAmI());
|
bool result = true;
|
||||||
|
printf("WHO AM I: 0x%2X\r\n\n", acc.getWhoAmI());
|
||||||
|
|
||||||
while (true) {
|
for (int i = 0; i < TEST_ITERATIONS; i++) {
|
||||||
printf("-----------\r\n");
|
if (i < TEST_ITERATIONS_SKIP) {
|
||||||
printf("acc_x: %d\r\n", acc.getAccX());
|
// Skip first 5 measurements
|
||||||
printf("acc_y: %d\r\n", acc.getAccY());
|
continue;
|
||||||
printf("acc_z: %d\r\n", acc.getAccZ());
|
}
|
||||||
|
const float g_vect_len = calc_3d_vector_len(acc.getAccX(), acc.getAccY(), acc.getAccZ()) / MMA8451_DIGITAL_SENSITIVITY;
|
||||||
wait(1);
|
const float deviation = fabs(g_vect_len - 1.0);
|
||||||
|
const char *succes_str = deviation <= MEASURE_DEVIATION_TOLERANCE ? "[OK]" : "[FAIL]";
|
||||||
|
result = result && (deviation <= MEASURE_DEVIATION_TOLERANCE);
|
||||||
|
printf("X:% 6d Y:% 6d Z:% 5d GF:%0.3fg, dev:%0.3f ... %s\r\n", acc.getAccX(), acc.getAccY(), acc.getAccZ(), g_vect_len, deviation, succes_str);
|
||||||
|
wait(0.5);
|
||||||
led = !led;
|
led = !led;
|
||||||
}
|
}
|
||||||
|
notify_completion(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,69 @@
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
#include "EthernetInterface.h"
|
#include "EthernetInterface.h"
|
||||||
|
|
||||||
const char* ECHO_SERVER_ADDRESS = "10.2.200.57";
|
struct s_ip_address
|
||||||
const int ECHO_PORT = 7;
|
{
|
||||||
|
int ip_1;
|
||||||
|
int ip_2;
|
||||||
|
int ip_3;
|
||||||
|
int ip_4;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAX_ECHO_LOOPS 100
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
char buffer[256] = {0};
|
||||||
|
char out_buffer[] = "Hello World\n";
|
||||||
|
char out_success[] = "{{success}}\n{{end}}\n";
|
||||||
|
char out_failure[] = "{{failure}}\n{{end}}\n";
|
||||||
|
s_ip_address ip_addr = {0, 0, 0, 0};
|
||||||
|
int port = 0;
|
||||||
|
|
||||||
|
printf("TCPCllient waiting for server IP and port...\r\n");
|
||||||
|
scanf("%d.%d.%d.%d:%d", &ip_addr.ip_1, &ip_addr.ip_2, &ip_addr.ip_3, &ip_addr.ip_4, &port);
|
||||||
|
printf("Address received:%d.%d.%d.%d:%d\r\n", ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4, port);
|
||||||
|
|
||||||
EthernetInterface eth;
|
EthernetInterface eth;
|
||||||
eth.init(); //Use DHCP
|
eth.init(); //Use DHCP
|
||||||
eth.connect();
|
eth.connect();
|
||||||
printf("IP Address is %s\n", eth.getIPAddress());
|
|
||||||
|
printf("TCPClient IP Address is %s\r\n", eth.getIPAddress());
|
||||||
|
sprintf(buffer, "%d.%d.%d.%d", ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4);
|
||||||
|
|
||||||
TCPSocketConnection socket;
|
TCPSocketConnection socket;
|
||||||
|
while (socket.connect(buffer, port) < 0) {
|
||||||
while (true) {
|
printf("TCPCllient unable to connect to %s:%d\r\n", buffer, port);
|
||||||
while (socket.connect(ECHO_SERVER_ADDRESS, ECHO_PORT) < 0) {
|
|
||||||
printf("Unable to connect to (%s) on port (%d)\n", ECHO_SERVER_ADDRESS, ECHO_PORT);
|
|
||||||
wait(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
char hello[] = "Hello World\n";
|
|
||||||
socket.send_all(hello, sizeof(hello) - 1);
|
|
||||||
|
|
||||||
char buf[256];
|
|
||||||
int n = socket.receive(buf, 256);
|
|
||||||
buf[n] = '\0';
|
|
||||||
printf("%s", buf);
|
|
||||||
|
|
||||||
socket.close();
|
|
||||||
wait(1);
|
wait(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test loop for multiple client conenctions
|
||||||
|
bool result = true;
|
||||||
|
int count_error = 0;
|
||||||
|
for (int i = 0; i < MAX_ECHO_LOOPS; i++) {
|
||||||
|
socket.send_all(out_buffer, sizeof(out_buffer) - 1);
|
||||||
|
|
||||||
|
int n = socket.receive(buffer, sizeof(buffer));
|
||||||
|
if (n > 0)
|
||||||
|
{
|
||||||
|
buffer[n] = '\0';
|
||||||
|
printf("%s", buffer);
|
||||||
|
bool echoed = strncmp(out_buffer, buffer, sizeof(out_buffer) - 1) == 0;
|
||||||
|
result = result && echoed;
|
||||||
|
if (echoed == false) {
|
||||||
|
count_error++; // Count error messages
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Loop messages passed: %d/%d\r\n", MAX_ECHO_LOOPS - count_error, MAX_ECHO_LOOPS);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
socket.send_all(out_success, sizeof(out_success) - 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
socket.send_all(out_failure, sizeof(out_failure) - 1);
|
||||||
|
}
|
||||||
|
socket.close();
|
||||||
eth.disconnect();
|
eth.disconnect();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,14 +39,14 @@ int main()
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
const char *url_httpbin_post = "http://httpbin.org/post";
|
const char *url_httpbin_post = "http://httpbin.org/post";
|
||||||
HTTPMap map;
|
|
||||||
HTTPText text(http_request_buffer, BUFFER_SIZE);
|
HTTPText text(http_request_buffer, BUFFER_SIZE);
|
||||||
|
HTTPMap map;
|
||||||
map.put("Hello", "World");
|
map.put("Hello", "World");
|
||||||
map.put("test", "1234");
|
map.put("test", "1234");
|
||||||
printf("HTTP_POST: Trying to post data to '%s' ...\r\n", url_httpbin_post);
|
printf("HTTP_POST: Trying to post data to '%s' ...\r\n", url_httpbin_post);
|
||||||
const int ret = http.post(url_httpbin_post, map, &text);
|
const int ret = http.post(url_httpbin_post, map, &text);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
printf("HTTP_POST: Read %d chars ... [OK]\n", strlen(http_request_buffer));
|
printf("HTTP_POST: Read %d chars ... [OK]\r\n", strlen(http_request_buffer));
|
||||||
printf("HTTP_POST: %s\r\n", http_request_buffer);
|
printf("HTTP_POST: %s\r\n", http_request_buffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -391,9 +391,12 @@ def get_result_summary_table():
|
||||||
counter_dict_test_id_types_all = dict((t, 0) for t in unique_test_id)
|
counter_dict_test_id_types_all = dict((t, 0) for t in unique_test_id)
|
||||||
|
|
||||||
test_properties = ['id', 'automated', 'description', 'peripherals', 'host_test', 'duration']
|
test_properties = ['id', 'automated', 'description', 'peripherals', 'host_test', 'duration']
|
||||||
|
|
||||||
|
# All tests status table print
|
||||||
pt = PrettyTable(test_properties)
|
pt = PrettyTable(test_properties)
|
||||||
for col in test_properties:
|
for col in test_properties:
|
||||||
pt.align[col] = "l" # Left align
|
pt.align[col] = "l"
|
||||||
|
pt.align['duration'] = "r"
|
||||||
|
|
||||||
counter_all = 0
|
counter_all = 0
|
||||||
counter_automated = 0
|
counter_automated = 0
|
||||||
|
@ -414,16 +417,32 @@ def get_result_summary_table():
|
||||||
counter_all += 1
|
counter_all += 1
|
||||||
counter_dict_test_id_types_all[test_id_prefix] += 1
|
counter_dict_test_id_types_all[test_id_prefix] += 1
|
||||||
print pt
|
print pt
|
||||||
print "Result:"
|
|
||||||
percent_progress = round(100.0 * counter_automated / float(counter_all), 2)
|
|
||||||
print "\tAutomated: %d / %d (%s %%)" % (counter_automated, counter_all, percent_progress)
|
|
||||||
print
|
print
|
||||||
|
|
||||||
|
# Automation result summary
|
||||||
|
test_id_cols = ['automated', 'all', 'percent [%]', 'progress']
|
||||||
|
pt = PrettyTable(test_id_cols)
|
||||||
|
pt.align['automated'] = "r"
|
||||||
|
pt.align['all'] = "r"
|
||||||
|
pt.align['percent [%]'] = "r"
|
||||||
|
|
||||||
|
percent_progress = round(100.0 * counter_automated / float(counter_all), 1)
|
||||||
|
str_progress = progress_bar(percent_progress, 75)
|
||||||
|
pt.add_row([counter_automated, counter_all, percent_progress, str_progress])
|
||||||
|
print "Automation coverage:"
|
||||||
|
print pt
|
||||||
|
print
|
||||||
|
|
||||||
|
# Test automation coverage table print
|
||||||
test_id_cols = ['id', 'automated', 'all', 'percent [%]', 'progress']
|
test_id_cols = ['id', 'automated', 'all', 'percent [%]', 'progress']
|
||||||
pt = PrettyTable(test_id_cols)
|
pt = PrettyTable(test_id_cols)
|
||||||
pt.align['id'] = "l" # Left align
|
pt.align['id'] = "l"
|
||||||
|
pt.align['automated'] = "r"
|
||||||
|
pt.align['all'] = "r"
|
||||||
|
pt.align['percent [%]'] = "r"
|
||||||
for unique_id in unique_test_id:
|
for unique_id in unique_test_id:
|
||||||
# print "\t\t%s: %d / %d" % (unique_id, counter_dict_test_id_types[unique_id], counter_dict_test_id_types_all[unique_id])
|
# print "\t\t%s: %d / %d" % (unique_id, counter_dict_test_id_types[unique_id], counter_dict_test_id_types_all[unique_id])
|
||||||
percent_progress = round(100.0 * counter_dict_test_id_types[unique_id] / float(counter_dict_test_id_types_all[unique_id]), 2)
|
percent_progress = round(100.0 * counter_dict_test_id_types[unique_id] / float(counter_dict_test_id_types_all[unique_id]), 1)
|
||||||
str_progress = progress_bar(percent_progress, 75)
|
str_progress = progress_bar(percent_progress, 75)
|
||||||
row = [unique_id,
|
row = [unique_id,
|
||||||
counter_dict_test_id_types[unique_id],
|
counter_dict_test_id_types[unique_id],
|
||||||
|
@ -431,7 +450,9 @@ def get_result_summary_table():
|
||||||
percent_progress,
|
percent_progress,
|
||||||
"[" + str_progress + "]"]
|
"[" + str_progress + "]"]
|
||||||
pt.add_row(row)
|
pt.add_row(row)
|
||||||
|
print "Test automation coverage:"
|
||||||
print pt
|
print pt
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
def progress_bar(percent_progress, saturation=0):
|
def progress_bar(percent_progress, saturation=0):
|
||||||
|
@ -545,7 +566,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
if opts.test_only_peripheral and not test.peripherals:
|
if opts.test_only_peripheral and not test.peripherals:
|
||||||
if opts.verbose:
|
if opts.verbose:
|
||||||
print "TargetTest::%s::NotPeripheralTestSkipped(%s)" % (target, ",".join(test.peripherals))
|
print "TargetTest::%s::NotPeripheralTestSkipped()" % (target)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if test.automated and test.is_supported(target, toolchain):
|
if test.automated and test.is_supported(target, toolchain):
|
||||||
|
|
|
@ -660,6 +660,9 @@ TESTS = [
|
||||||
"id": "NET_13", "description": "TCP client echo loop",
|
"id": "NET_13", "description": "TCP client echo loop",
|
||||||
"source_dir": join(TEST_DIR, "net", "echo", "tcp_client_loop"),
|
"source_dir": join(TEST_DIR, "net", "echo", "tcp_client_loop"),
|
||||||
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY],
|
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY],
|
||||||
|
"automated": True,
|
||||||
|
"duration": 15,
|
||||||
|
"host_test": "tcpecho_client_auto",
|
||||||
"peripherals": ["ethernet"],
|
"peripherals": ["ethernet"],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -761,7 +764,9 @@ TESTS = [
|
||||||
"source_dir": join(TEST_DIR, "mbed", "i2c_MMA8451Q"),
|
"source_dir": join(TEST_DIR, "mbed", "i2c_MMA8451Q"),
|
||||||
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA8451Q')],
|
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA8451Q')],
|
||||||
"mcu": ["KL25Z", "KL05Z", "KL46Z"],
|
"mcu": ["KL25Z", "KL05Z", "KL46Z"],
|
||||||
},
|
"automated": True,
|
||||||
|
"duration": 15,
|
||||||
|
},
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue