Skip to content

Commit

Permalink
Merge pull request #105 from xmos/release/v4.2.1
Browse files Browse the repository at this point in the history
Release v4.2.1
  • Loading branch information
lucianomartin authored Sep 16, 2022
2 parents 0f0d845 + 4a324f0 commit 4870005
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 42 deletions.
7 changes: 0 additions & 7 deletions Brewfile

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Device control library change log
=================================

4.2.1
-----

* FIXED: Some errors were being printed to stdout, now all use stderr. Common
format also adopted

4.2.0
-----

Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@Library('xmos_jenkins_shared_library@v0.17.0') _
@Library('xmos_jenkins_shared_library@v0.18.0') _
getApproval()

pipeline {
agent {
label 'x86_64&&brew&&macOS'
label 'x86_64&&macOS'
}
environment {
REPO = 'lib_device_control'
Expand Down
15 changes: 8 additions & 7 deletions lib_device_control/host/device_access_i2c_rpi.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2021 XMOS LIMITED.
// Copyright 2016-2022 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#if USE_I2C && RPI

Expand All @@ -18,6 +18,7 @@

//#define DBG(x) x
#define DBG(x)
#define PRINT_ERROR(...) fprintf(stderr, "Error : " __VA_ARGS__)

/*Note there is an issue with RPI/Jessie where I2C repeated starts are not enabled by default.
Try the following at the bash command line to enable them:
Expand All @@ -38,13 +39,13 @@ control_ret_t control_init_i2c(unsigned char i2c_slave_address)
address = i2c_slave_address;

if ((fd = open(devName, O_RDWR)) < 0) { // Open port for reading and writing
fprintf(stderr, "Failed to open i2c port: ");
PRINT_ERROR("Failed to open i2c port: ");
perror( "" );
return CONTROL_ERROR;
}

if (ioctl(fd, I2C_SLAVE, address) < 0) { // Set the port options and set the address of the device we wish to speak to
fprintf(stderr, "Unable to set i2c configuration at address 0x%x: ", address);
PRINT_ERROR("Unable to set i2c configuration at address 0x%x: ", address);
perror( "" );
return CONTROL_ERROR;
}
Expand Down Expand Up @@ -74,7 +75,7 @@ control_write_command(control_resid_t resid, control_cmd_t cmd,

int written = write(fd, buffer_to_send, len);
if (written != len){
fprintf(stderr, "Error writing to i2c. %d of %d bytes sent\n", written, len);
PRINT_ERROR("Failed to write to i2c. %d of %d bytes sent\n", written, len);
return CONTROL_ERROR;
}

Expand All @@ -90,7 +91,7 @@ control_read_command(control_resid_t resid, control_cmd_t cmd,
unsigned char read_hdr[I2C_TRANSACTION_MAX_BYTES];
unsigned len = control_build_i2c_data(read_hdr, resid, cmd, payload, payload_len);
if (len != 3){
fprintf(stderr, "Error building read command section of read_device. len should be 3 but is %d\n", len);
PRINT_ERROR("Failed to read command section of read_device. len should be 3 but is %d\n", len);
return CONTROL_ERROR;
}

Expand Down Expand Up @@ -121,8 +122,8 @@ control_read_command(control_resid_t resid, control_cmd_t cmd,
int errno = ioctl( fd, I2C_RDWR, &rdwr_data );

if ( errno < 0 ) {
fprintf(stderr, "rdwr ioctl error %d: ", errno );
perror( "" );
PRINT_ERROR("Failed to transfer data, rdwr ioctl error number %d: ", errno );
perror( "Error :" );
return CONTROL_ERROR;
}

Expand Down
7 changes: 4 additions & 3 deletions lib_device_control/host/device_access_spi_rpi.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2021 XMOS LIMITED.
// Copyright 2017-2022 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#if USE_SPI && RPI

Expand All @@ -11,6 +11,7 @@

//#define DBG(x) x
#define DBG(x)
#define PRINT_ERROR(...) fprintf(stderr, "Error : " __VA_ARGS__)

static unsigned delay_milliseconds;

Expand All @@ -27,7 +28,7 @@ control_init_spi_pi(spi_mode_t spi_mode, bcm2835SPIClockDivider clock_divider, u
{
if(!bcm2835_init() ||
!bcm2835_spi_begin()) {
fprintf(stderr, "bcm2835 initialisation failed. Possibly not running as root\n");
PRINT_ERROR("BCM2835 initialisation failed. Possibly not running as root\n");
return CONTROL_ERROR;
}

Expand Down Expand Up @@ -86,4 +87,4 @@ control_cleanup_spi(void)
return CONTROL_SUCCESS;
}

#endif /* USE_SPI && RPI */
#endif /* USE_SPI && RPI */
27 changes: 14 additions & 13 deletions lib_device_control/host/device_access_usb.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2021 XMOS LIMITED.
// Copyright 2016-2022 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#if USE_USB
#include <stdio.h>
Expand All @@ -17,6 +17,7 @@

//#define DBG(x) x
#define DBG(x)
#define PRINT_ERROR(...) fprintf(stderr, "Error : " __VA_ARGS__)

static unsigned num_commands = 0;

Expand All @@ -34,11 +35,11 @@ static const int sync_timeout_ms = 500;
void debug_libusb_error(int err_code)
{
#if defined _WIN32
printf("libusb_control_transfer returned %s\n", usb_strerror());
PRINT_ERROR("libusb_control_transfer returned %s\n", usb_strerror());
#elif defined __APPLE__
printf("libusb_control_transfer returned %s\n", libusb_error_name(err_code));
PRINT_ERROR("libusb_control_transfer returned %s\n", libusb_error_name(err_code));
#elif defined __linux
printf("libusb_control_transfer returned %d\n", err_code);
PRINT_ERROR("libusb_control_transfer returned %d\n", err_code);
#endif

}
Expand Down Expand Up @@ -93,8 +94,8 @@ control_ret_t control_query_version(control_version_t *version)
static bool payload_len_exceeds_control_packet_size(size_t payload_len)
{
if (payload_len > USB_TRANSACTION_MAX_BYTES) {
printf("control transfer of %zd bytes requested\n", payload_len);
printf("maximum control packet size is %d\n", USB_TRANSACTION_MAX_BYTES);
PRINT_ERROR("Control transfer of %zd bytes requested\n", payload_len);
PRINT_ERROR("Maximum control packet size is %d\n", USB_TRANSACTION_MAX_BYTES);
return true;
}
else {
Expand Down Expand Up @@ -186,7 +187,7 @@ static control_ret_t find_xmos_device(int vendor_id, int product_id)
(dev->descriptor.idProduct == product_id)) {
devh = usb_open(dev);
if (!devh) {
fprintf(stderr, "failed to open device\n");
PRINT_ERROR("Failed to open device\n");
return CONTROL_ERROR;
}
break;
Expand All @@ -195,7 +196,7 @@ static control_ret_t find_xmos_device(int vendor_id, int product_id)
}

if (!devh) {
fprintf(stderr, "could not find device\n");
PRINT_ERROR("Could not find device\n");
return CONTROL_ERROR;
}

Expand All @@ -213,14 +214,14 @@ control_ret_t control_init_usb(int vendor_id, int product_id, int interface_num)

int r = usb_set_configuration(devh, 1);
if (r < 0) {
fprintf(stderr, "Error setting config 1\n");
PRINT_ERROR("Failed to set config 1\n");
usb_close(devh);
return CONTROL_ERROR;
}

r = usb_claim_interface(devh, interface_num);
if (r < 0) {
fprintf(stderr, "Error claiming interface %d %d\n", interface_num, r);
PRINT_ERROR("Failed to claim interface %d %d\n", interface_num, r);
return CONTROL_ERROR;
}

Expand All @@ -240,7 +241,7 @@ control_ret_t control_init_usb(int vendor_id, int product_id, int interface_num)
{
int ret = libusb_init(NULL);
if (ret < 0) {
fprintf(stderr, "failed to initialise libusb\n");
PRINT_ERROR("Failed to initialise libusb\n");
return CONTROL_ERROR;
}

Expand All @@ -258,12 +259,12 @@ control_ret_t control_init_usb(int vendor_id, int product_id, int interface_num)
}

if (dev == NULL) {
fprintf(stderr, "could not find device\n");
PRINT_ERROR("Could not find device\n");
return CONTROL_ERROR;
}

if (libusb_open(dev, &devh) < 0) {
fprintf(stderr, "failed to open device. Ensure adequate permissions\n");
PRINT_ERROR("Failed to open device. Ensure adequate permissions\n");
return CONTROL_ERROR;
}

Expand Down
19 changes: 10 additions & 9 deletions lib_device_control/host/device_access_xscope.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2021 XMOS LIMITED.
// Copyright 2016-2022 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#if USE_XSCOPE

Expand All @@ -18,6 +18,7 @@

//#define DBG(x) x
#define DBG(x)
#define PRINT_ERROR(...) fprintf(stderr, "Error : " __VA_ARGS__)

#define UNUSED_PARAMETER(x) (void)(x)

Expand Down Expand Up @@ -81,17 +82,17 @@ void record_callback(unsigned int id, unsigned long long timestamp,
control_ret_t control_init_xscope(const char *host_str, const char *port_str)
{
if (xscope_ep_set_print_cb(xscope_print) != XSCOPE_EP_SUCCESS) {
fprintf(stderr, "xscope_ep_set_print_cb failed\n");
PRINT_ERROR("xscope_ep_set_print_cb failed\n");
return CONTROL_ERROR;
}

if (xscope_ep_set_register_cb(register_callback) != XSCOPE_EP_SUCCESS) {
fprintf(stderr, "xscope_ep_set_register_cb failed\n");
PRINT_ERROR("xscope_ep_set_register_cb failed\n");
return CONTROL_ERROR;
}

if (xscope_ep_set_record_cb(record_callback) != XSCOPE_EP_SUCCESS) {
fprintf(stderr, "xscope_ep_set_record_cb failed\n");
PRINT_ERROR("xscope_ep_set_record_cb failed\n");
return CONTROL_ERROR;
}

Expand Down Expand Up @@ -122,7 +123,7 @@ control_ret_t control_query_version(control_version_t *version)
record_count = 0;

if (xscope_ep_request_upload(len, (unsigned char*)b) != XSCOPE_EP_SUCCESS) {
printf("xscope_ep_request_upload failed\n");
PRINT_ERROR("xscope_ep_request_upload failed\n");
return CONTROL_ERROR;
}

Expand Down Expand Up @@ -155,8 +156,8 @@ control_ret_t control_query_version(control_version_t *version)
static bool upload_len_exceeds_xscope_limit(size_t len)
{
if (len > XSCOPE_UPLOAD_MAX_BYTES) {
printf("upload of %zd bytes requested\n", len);
printf("maximum upload size is %d\n", XSCOPE_UPLOAD_MAX_BYTES);
PRINT_ERROR("Upload of %zd bytes requested\n", len);
PRINT_ERROR("Maximum upload size is %d\n", XSCOPE_UPLOAD_MAX_BYTES);
return true;
}
else {
Expand All @@ -182,7 +183,7 @@ control_write_command(control_resid_t resid, control_cmd_t cmd,
record_count = 0;

if (xscope_ep_request_upload(len, (unsigned char*)b) != XSCOPE_EP_SUCCESS) {
printf("xscope_ep_request_upload failed\n");
PRINT_ERROR("xscope_ep_request_upload failed\n");
return CONTROL_ERROR;
}
// wait for response on xSCOPE probe
Expand Down Expand Up @@ -212,7 +213,7 @@ control_read_command(control_resid_t resid, control_cmd_t cmd,
record_count = 0;

if (xscope_ep_request_upload(len, (unsigned char*)b) != XSCOPE_EP_SUCCESS) {
printf("xscope_ep_request_upload failed\n");
PRINT_ERROR("xscope_ep_request_upload failed\n");
return CONTROL_ERROR;
}

Expand Down
2 changes: 1 addition & 1 deletion lib_device_control/module_build_info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = 4.2.0
VERSION = 4.2.1

DEPENDENT_MODULES = lib_xassert(>=4.0.0) \
lib_logging(>=3.0.0)
Expand Down

0 comments on commit 4870005

Please sign in to comment.