Porting OpenLog Library

I’m trying to port Sparkfun’s OpenLog library to Particle, and have run into a challenge.

I’ve been referencing this porting guide, but am running into an issue with a library OpenLog is dependent on - SerialPort, which I think is an enhanced version of the core arduino serial library.

In SerialPort.h, it includes:

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <Arduino.h>

I haven’t dealt with the avr/io.h library. I assume it needs to be ported in a similar way as the avr/pgmspace.h library, but I don’t know how to do that. Will it be similar to how avr/pgmspace.h is currently dealt with in porting, or something more complex?

Thanks!

@homemaltster, when you say “Particle” do you have a specific device in mind (eg. Photono)? The SerialPort library provides low-level ring buffering which can’t be implemented as-is on Particle devices. However, it may be possible to use a FreeRTOS thread to create a reliable ring buffer using the low level FIFO buffer implemented in the DeviceOS. It may even be possible to implement without a thread since the Photon, for example, runs at a much faster clock than an ATMega328.

Hi @peekay123,

Thanks for the quick response!

I’m using a P1. I’ve never done this sort of porting before - any resources or help you could point me towards?

As so often, @rickkas7 has got something in that direction already

1 Like

@homemaltster, the Particle platform has supported Arduino apps for a while now. The issue here is not the code but the hardware. More specifically, the serial hardware. The SDFat library that is available for Particle is from the same author of the SDFat library used by OpenLog so there is not a lot of porting there.

However, perhaps you can explain why you want to port OpenLog and what you are trying to achieve.

@peekay123, I’ve built a malting machine, aimed at developing local supply chains for craft brewers, & connecting local farmers and brewers.

I’m trying to make an offline expansion system so the machine can be run in places without wifi, instead of spinning a new board with an electron. I’ve built a little expansion box that can plug into the main machine, and has an SD card reader and the openlog board from Sparkfun. The goal is to be able to upload recipes to the machine, datalog from it, and flash new firmware.

@homemaltster, you don't need OpenLog then. You can program the Photon to interface to the machines via a hardware serial port. You can build a simple logger (see @rickkas7 many posts that might apply) that write to an attached microSD card. However, if the device is offline, how can you:

@rickkas7's github contains some great nuggets like the SdCardLogHandlerRK or SerialBufferRK

2 Likes

@peekay123, thanks for the resources!

The SD Card stores recipes, firmware, and data. Information on the SD card then is either uploaded to or downloaded from a website, where recipes are made or data is visualized.

I only have UART available on my pcb for this feature, which is why I thought OpenLog was a good path to pursue. If I had SPI broken out, it would be great to jump on the SdCardLogHandlerRk, but that’s not an option currently. I’m investigating if @rickkas7’s SerialBufferRk can replace the SerialPort library in OpenLog.

1 Like