With generic devices, can we link to Arduino libraries?
Can we create object files? I have some code covered by an NDA that I need to hide.
Using Arduino libraries
Re: Using Arduino libraries
Firstly, it is important to note that Arduino "libraries" are not object libraries that can be incorporated into an application at link time. Rather, they are collections of source code that the Arduino IDE causes to be compiled along with your application code. The object files resulting from that compilation are then linked together with the standard C/C++ libraries to produce an executable image.dlh wrote:With generic devices, can we link to Arduino libraries?
If you have an Arduino "library" that doesn't use any of the Arduino core functions (e.g. millis(), digitalWrite(), etc.) then it can probably be made part of a ZBasic application whether targeted to a ZX or a generic AVR device.
For Arduino "library" code that does use Arduino core functions (many of which provide the same or similar functionality as ZBasic System Library routines), you would need some interface code that implements the Arduino core functions in a manner that is compatible with ZBasic.
I have successfully used the Arduino Ethernet "library" code to add Ethernet connectivity to a ZBasic device both using an Arduino Ethernet Shield and using a vanilla Wiznet W5100 module. To achieve this I created a ZBasic/Arduino interface layer that provides all of the capabilities of the Arduino core code (found in the hardware/arduino/cores/arduino subdirectory of the Arduino installation directory). Some of the Arduino core files were used directly without modification, some needed slight modification and others were replaced completely.
I am in the process of writing an application note on the use of the ZBasic/Arduino interface code that will describe the issues that might arise and how they might be addressed. A second application note is planned describing the use of the Arduino Ethernet "library".
Yes. The easiest way is to create an object library (a .a file) and distribute that. See Section 6.7 of the ZBasic Language Reference Manual.dlh wrote:Can we create object files? I have some code covered by an NDA that I need to hide.
I've added a post to the Files forum with a simple example of creating a library.
- Don Kinzer
The ZBasic code is just a wrapper over the Arduino Ethernet "library" code. Consequently, the ZBasic/Arduino core code is needed, too. I'm planning to write one application note on the ZBasic/Arduino core code and a second one on using Arduino "libraries" with the Ethernet as an example. Code will be included with both.stevech wrote:WizNet 5100 code.. in ZBasic? Mind sharing it?
- Don Kinzer
Ah.
I have WizNet 5100 C code for UDP, TCP, FTP client, and so on. The WizNet example code was not used because my code needed to be interrupt driven for all 4 sockets, so there'd be no looping. I started on a translation the C code to ZBasic long ago, but decided that most AVRs just don't have enough RAM, though the large-ish buffers in the W5100 chip can be used cleverly, e.g., leave the data there until you are ready to copy/process the next small hunk using AVR RAM.
I had some challenges with the 5100 chip... Lacks adaptive TCP ACK timeout and adaptive TCP window size - needed for cellular. It was a bear to do this, until I finally disabled windowing to prevent TCP timeouts and retransmissios by the other end. I also wired up one of the RJ45 Link-LED bits to the software could "see" if the media is disconnected or the far end switch is off. Else packets just build up in the W5100 buffer with no viable way to know why.
Next go-round, I'd look at their newest chip that again supports SPI. Their successor to the 5100 didn't.
So it's working well, with these and other subtle lessons learned, for an app that just has to run 24/7 unattended (100 sites).
I have WizNet 5100 C code for UDP, TCP, FTP client, and so on. The WizNet example code was not used because my code needed to be interrupt driven for all 4 sockets, so there'd be no looping. I started on a translation the C code to ZBasic long ago, but decided that most AVRs just don't have enough RAM, though the large-ish buffers in the W5100 chip can be used cleverly, e.g., leave the data there until you are ready to copy/process the next small hunk using AVR RAM.
I had some challenges with the 5100 chip... Lacks adaptive TCP ACK timeout and adaptive TCP window size - needed for cellular. It was a bear to do this, until I finally disabled windowing to prevent TCP timeouts and retransmissios by the other end. I also wired up one of the RJ45 Link-LED bits to the software could "see" if the media is disconnected or the far end switch is off. Else packets just build up in the W5100 buffer with no viable way to know why.
Next go-round, I'd look at their newest chip that again supports SPI. Their successor to the 5100 didn't.
So it's working well, with these and other subtle lessons learned, for an app that just has to run 24/7 unattended (100 sites).