Arduino shield and Arduino DUE

@ianr seems like you have done the patch correctly. However, I don’t think your minimalist sketch should work, even in the Uno, if it does, perhaps it should not. You need to create a device using cc.newDevice.

Did you try to run the Pot or Button examples in your Due Arduino?

Hi @ricardocrudo, thanks for this - good point! I’ve done a check and the Uno is recognised by the Mod Duo without (and with!) cc.newDevice in the minimalist sketch. The Due doesn’t work either way.

I’ve tried the Button example and that doesn’t work on the Due.

I’ve pretty much run out of ideas now, other than trying on a completely different PC. I’ve got a linux machine and might try that by way of a complete change.

The only other thought would be if you could provide a zip of a known working set of files…but I don’t want to distract you from more important work!

Ian

I’ll find some time this week and test with the Due I have here. I’ll let you know.

That would be great - thanks!

@ianr @CharlyRebell I’ve found a bug in the Due’s code. There is a new version of the library (v0.5.1) already released with the fix in place. I’ve tested it here with the Pot example and it’s working well. Let me know if it works for you too.

2 Likes

Sorry to say I’ve still not been able to get it working :frowning:

I had a go during the week from my desktop PC but no joy so thought I’d have a more of a go on my laptop.

I deleted the old control chain folder, then downloaded 0.5.1 and did an “Add ZIP Library…” from the Arduino IDE.

Installed the Due board to the Arduino IDE.

Tried to compile but got an error because I hadn’t updated variant.cpp to add “attribute((weak));” - duly updated and then it complied and deployed OK.

…but still not recognised by the MOD Duo :frowning:

I see you’ve modified ReUART.cpp and it no longer has the if statement that we had to change before - is there anything else to be modified in it? Or anything else I’ve missed?

Thanks

Ian

No, you no longer need to change it.

I have update the README of the library with some debugging information. Please check it out and let me know if it helps you to isolate the problem. https://github.com/moddevices/cc-arduino-lib

Thanks Ricardo,

I’ve had a read through but can’t see anything I’ve missed. If it’s really just a case of downloading the new version of the controlchain library and updating variant.cpp I can’t think of what else could be different for me, unless I’ve managed to somehow damage both my DUE boards.

Given that all I ever really needed was a bit more memory I’ve just ordered a Mega - arrives tomorrow - will see how I fair with that!

Ian

Did you try to run the cc-master locally and connect the arduino to your laptop via usb?

Ah no! Didn’t spot the debugging info when I followed that link an hour ago! Maybe my browser cached the old page or something. Will definitely give that a try.

Er, presumably this needs to be a laptop running linux?

Work out-of-the-box for Linux and maybe for Mac too. For Windows you’ll need a VM, docker or perhaps this https://docs.microsoft.com/en-us/windows/wsl/install-win10.

Hmm…not having much success I’m afraid. I had a go from linux (Ubuntu on an old Macbook Pro) but when I get to the /waf build stage (having installed jansson and libserialport) I get an error:

[ 3/21] Compiling lib/src/core.c
23:51:33 runner [’/usr/bin/gcc’, ‘-Wall’, ‘-Wextra’, ‘-std=gnu99’, ‘-O3’, ‘-Wall’, ‘-Wextra’, ‘-std=gnu99’, ‘-O3’, ‘-Wall’, ‘-Wextra’, ‘-std=gnu99’, ‘-O3’, ‘-fPIC’, ‘-DPYTHONDIR="/usr/local/lib/python2.7/dist-packages"’, ‘-DPYTHONARCHDIR="/usr/local/lib/python2.7/dist-packages"’, ‘…/lib/src/core.c’, ‘-c’, ‘-o/home/ianr/Desktop/cc-arduino-lib-master/cc-master-master/build/lib/src/core.c.3.o’]
[ 6/21] Compiling lib/src/msg.c
23:51:33 runner [’/usr/bin/gcc’, ‘-Wall’, ‘-Wextra’, ‘-std=gnu99’, ‘-O3’, ‘-Wall’, ‘-Wextra’, ‘-std=gnu99’, ‘-O3’, ‘-Wall’, ‘-Wextra’, ‘-std=gnu99’, ‘-O3’, ‘-fPIC’, ‘-DPYTHONDIR="/usr/local/lib/python2.7/dist-packages"’, ‘-DPYTHONARCHDIR="/usr/local/lib/python2.7/dist-packages"’, ‘…/lib/src/msg.c’, ‘-c’, ‘-o/home/ianr/Desktop/cc-arduino-lib-master/cc-master-master/build/lib/src/msg.c.3.o’]
…/lib/src/core.c: In function ‘serial_setup’:
…/lib/src/core.c:177:31: error: ‘SP_MODE_READ_WRITE’ undeclared (first use in this function)
ret = sp_open(handle->sp, SP_MODE_READ_WRITE);
^
…/lib/src/core.c:177:31: note: each undeclared identifier is reported only once for each function it appears in
…/lib/src/core.c:188:26: warning: implicit declaration of function ‘sp_get_port_usb_manufacturer’ [-Wimplicit-function-declaration]
char *manufacturer = sp_get_port_usb_manufacturer(handle->sp);
^
…/lib/src/core.c:188:26: warning: initialization makes pointer from integer without a cast [-Wint-conversion]

Thought I’d try it on another machine so span-up a Raspberry Pi!
With that I get the following error when I do a sudo ./waf build:

pi@raspberrypi:~/Desktop/cc-master-master $ sudo ./waf build -v
Waf: Entering directory `/home/pi/Desktop/cc-master-master/build’
[18/20] Compiling client/src/cc_client.c
00:14:49 runner [’/usr/bin/gcc’, ‘-Wall’, ‘-Wextra’, ‘-std=gnu99’, ‘-O3’, ‘-Wall’, ‘-Wextra’, ‘-std=gnu99’, ‘-O3’, ‘-Wall’, ‘-Wextra’, ‘-std=gnu99’, ‘-O3’, ‘-fPIC’, ‘-Ilib/src’, ‘-I…/lib/src’, ‘-DPYTHONDIR="/usr/local/lib/python2.7/dist-packages"’, ‘-DPYTHONARCHDIR="/usr/local/lib/python2.7/dist-packages"’, ‘…/client/src/cc_client.c’, ‘-c’, ‘-o/home/pi/Desktop/cc-master-master/build/client/src/cc_client.c.4.o’]
…/client/src/cc_client.c:34:21: fatal error: request.h: No such file or directory
#include “request.h”
^
compilation terminated.

A bit frustrating…will try and have more of a look tomorrow…

Tried again on my windows PC using the windows subsystem for linux (which I’d installed a while ago but not had the chance to play with). Got the same error as the Macbook (SP_MODE_READ_WRITE undeclared). Maybe it’s a version thing…

You are missing the dependencies. Before build, install first libserialport and jansson.

I didn’t install them originally and it didn’t get this far, but all these issues are since the dependencies were installed :-/

The most meaningful error I can see at the moment is
[17/21] Compiling client/src/cc_client.c
…/lib/src/core.c: In function ‘serial_setup’:
…/lib/src/core.c:177:31: error: ‘SP_MODE_READ_WRITE’ undeclared (first use in this function)
ret = sp_open(handle->sp, SP_MODE_READ_WRITE);

Is that it trying to get to the libserialport library and not finding it?

Actually the first error I get when running sudo ./waf build -v is:

[18/21] Compiling client/src/sockcli.c
21:07:50 runner ['/usr/bin/gcc', '-Wall', '-Wextra', '-std=gnu99', '-O3', '-Wall', '-Wextra', '-std=gnu99', '-O3', '-Wall', '-Wextra', '-std=gnu99', '-O3', '-fPIC', '-Ilib/src', '-I../lib/src', '-DPYTHONDIR="/usr/local/lib/python2.7/dist-packages"', '-DPYTHONARCHDIR="/usr/local/lib/python2.7/dist-packages"', '../client/src/cc_client.c', '-c', '-o/mnt/c/DEV/ArduinoFiles/cc-master-master/build/client/src/cc_client.c.4.o']
21:07:50 runner ['/usr/bin/gcc', '-Wall', '-Wextra', '-std=gnu99', '-O3', '-Wall', '-Wextra', '-std=gnu99', '-O3', '-Wall', '-Wextra', '-std=gnu99', '-O3', '-fPIC', '-Ilib/src', '-I../lib/src', '-DPYTHONDIR="/usr/local/lib/python2.7/dist-packages"', '-DPYTHONARCHDIR="/usr/local/lib/python2.7/dist-packages"', '../client/src/sockcli.c', '-c', '-o/mnt/c/DEV/ArduinoFiles/cc-master-master/build/client/src/sockcli.c.4.o']
../client/src/base64.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
 ../../server/src/base64.c
 ^

It seemed to be trying to point cc_base64.h and cc_base64.c in the client folder to the server versions but that failed to work. So I copied the content from the server’s cc_base64.h and base64.c into the client’s files and it then proceeded OK until I hit the SP_MODE_READ_WRITE error that I mentioned previously. Here’s the verbose output:

[17/21] Compiling client/src/cc_client.c
01:09:27 runner ['/usr/bin/gcc', '-Wall', '-Wextra', '-std=gnu99', '-O3', '-Wall', '-Wextra', '-std=gnu99', '-O3', '-Wall', '-Wextra', '-std=gnu99', '-O3', '-fPIC', '-Ilib/src', '-I../lib/src', '-DPYTHONDIR="/usr/local/lib/python2.7/dist-packages"', '-DPYTHONARCHDIR="/usr/local/lib/python2.7/dist-packages"', '../client/src/cc_client.c', '-c', '-o/mnt/c/DEV/ArduinoFiles/cc-master-master/build/client/src/cc_client.c.4.o']
../lib/src/core.c: In function ‘serial_setup’:
../lib/src/core.c:177:31: error: ‘SP_MODE_READ_WRITE’ undeclared (first use in this function)
     ret = sp_open(handle->sp, SP_MODE_READ_WRITE);
                               ^
../lib/src/core.c:177:31: note: each undeclared identifier is reported only once for each function it appears in
../lib/src/core.c:188:26: warning: implicit declaration of function ‘sp_get_port_usb_manufacturer’ [-Wimplicit-function-declaration]
     char *manufacturer = sp_get_port_usb_manufacturer(handle->sp);
                          ^
../lib/src/core.c:188:26: warning: initialization makes pointer from integer without a cast [-Wint-conversion]

In file included from ../client/src/cc_client.c:34:0:
../client/src/request.h:1:1: error: expected identifier or ‘(’ before ‘.’ token
 ../../server/src/request.h
 ^
In file included from ../client/src/cc_client.c:35:0:
../client/src/sockcli.h:64:1: error: unknown type name ‘sockcli_t’
 sockcli_t* sockcli_init(const char *path);
 ^
../client/src/sockcli.h:65:21: error: unknown type name ‘sockcli_t’
 void sockcli_finish(sockcli_t *client);
                     ^
../client/src/sockcli.h:66:18: error: unknown type name ‘sockcli_t’
 int sockcli_read(sockcli_t *client, void *buffer, size_t size);
                  ^
../client/src/sockcli.h:67:19: error: unknown type name ‘sockcli_t’
 int sockcli_write(sockcli_t *client, const void *buffer, size_t size);
                   ^
../client/src/cc_client.c:63:5: error: unknown type name ‘sockcli_t’
     sockcli_t *socket;
     ^
../client/src/cc_client.c: In function ‘reader’:
../client/src/cc_client.c:94:17: warning: implicit declaration of function ‘sockcli_read’ [-Wimplicit-function-declaration]
         int n = sockcli_read(client->socket, buffer, READ_BUFFER_SIZE);
                 ^
../client/src/cc_client.c:121:39: error: ‘CC_DEV_STATUS_EVENT_FORMAT’ undeclared (first use in this function)
                     json_unpack(data, CC_DEV_STATUS_EVENT_FORMAT,
                                       ^
../client/src/cc_client.c:121:39: note: each undeclared identifier is reported only once for each function it appears in../client/src/cc_client.c:135:39: error: ‘CC_DATA_UPDATE_EVENT_FORMAT’ undeclared (first use in this function)
                     json_unpack(data, CC_DATA_UPDATE_EVENT_FORMAT,
                                       ^
../client/src/cc_client.c: In function ‘cc_client_request’:
../client/src/cc_client.c:178:15: warning: implicit declaration of function ‘sockcli_write’ [-Wimplicit-function-declaration]
     int ret = sockcli_write(client->socket, request_str, strlen(request_str) + 1);
               ^
../client/src/cc_client.c: In function ‘cc_client_delete’:
../client/src/cc_client.c:238:5: warning: implicit declaration of function ‘sockcli_finish’ [-Wimplicit-function-declaration]
     sockcli_finish(client->socket);
     ^
../client/src/cc_client.c: In function ‘cc_client_assignment’:
../client/src/cc_client.c:262:38: error: ‘CC_ASSIGNMENT_REQ_FORMAT’ undeclared (first use in this function)
     json_t *request_data = json_pack(CC_ASSIGNMENT_REQ_FORMAT,
                                      ^
../client/src/cc_client.c:282:27: error: ‘CC_ASSIGNMENT_REPLY_FORMAT’ undeclared (first use in this function)
         json_unpack(data, CC_ASSIGNMENT_REPLY_FORMAT, "assignment_id", &assignment_id);
                           ^
../client/src/cc_client.c: In function ‘cc_client_unassignment’:
../client/src/cc_client.c:298:38: error: ‘CC_UNASSIGNMENT_REQ_FORMAT’ undeclared (first use in this function)
     json_t *request_data = json_pack(CC_UNASSIGNMENT_REQ_FORMAT,
                                      ^
../client/src/cc_client.c: In function ‘cc_client_device_list’:
../client/src/cc_client.c:313:38: error: ‘CC_DEV_LIST_REQ_FORMAT’ undeclared (first use in this function)
     json_t *request_data = json_pack(CC_DEV_LIST_REQ_FORMAT);
                                      ^
../client/src/cc_client.c: In function ‘cc_client_device_descriptor’:
../client/src/cc_client.c:339:38: error: ‘CC_DEV_DESCRIPTOR_REQ_FORMAT’ undeclared (first use in this function)
     json_t *request_data = json_pack(CC_DEV_DESCRIPTOR_REQ_FORMAT,
                                      ^
../client/src/cc_client.c: In function ‘cc_client_device_disable’:
../client/src/cc_client.c:357:38: error: ‘CC_DEV_CONTROL_REQ_FORMAT’ undeclared (first use in this function)
     json_t *request_data = json_pack(CC_DEV_CONTROL_REQ_FORMAT, "device_id", device_id,
                                      ^
../client/src/cc_client.c: In function ‘cc_client_device_status_cb’:
../client/src/cc_client.c:374:38: error: ‘CC_DEV_STATUS_REQ_FORMAT’ undeclared (first use in this function)
     json_t *request_data = json_pack(CC_DEV_STATUS_REQ_FORMAT, "enable", enable);
                                      ^
../client/src/cc_client.c: In function ‘cc_client_data_update_cb’:
../client/src/cc_client.c:390:38: error: ‘CC_DATA_UPDATE_REQ_FORMAT’ undeclared (first use in this function)
     json_t *request_data = json_pack(CC_DATA_UPDATE_REQ_FORMAT, "enable", enable);

Feel a bit out of my depth with this stuff but one final question:

Should a Mega 2560 R3 be a drop in replacement for the UNO? I was naively assuming that it would be, but I find that that doesn’t work either.

Is there anything I should’ve changed to get that working?

Thanks

Ian