Skip to content

Commit

Permalink
0.5.2-20201223
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpool committed Dec 23, 2020
1 parent e9d185c commit 75f32e8
Show file tree
Hide file tree
Showing 9 changed files with 1,888 additions and 1,741 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ This CHANGELOG file should help that the library becomes a standardized open sou
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased] - 2020-12-21
## [Unreleased] - 2020-12-23

## [0.5.2] - 2020-12-23
### Added
- Low Level funtion LogoClient::ReadBlock
- Security function LogoClient::SetSessionPassword
- Security function LogoClient::ClearSessionPassword
- Logging (library ArduinoLog)

### Changed
- Protection Level in GetProtection
- Update Library Reference Manual (RefManual.md) to Rev. Ai
- DTE Interface Images
- Update Examples for Arduino MEGA: CyclicReading, FetchDataDemo, ProtocolTester

### Fixed
- GetOrderCode: Support of 0BA6.ES10
- StreamConnect: Clearing serial buffer for Reconnection
- ReadArea: VM Mapping (correct access to the program space)
- Reduce some compiler warnings

## [0.5.1] - 2018-09-18
### Added
Expand Down Expand Up @@ -145,6 +149,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- LICENCE.md added to the project
- README.md added to the project

[Unreleased]: https://github.com/brickpool/logo/compare/v0.5.1...HEAD
[Unreleased]: https://github.com/brickpool/logo/compare/v0.5.2...HEAD
[0.5.2]: https://github.com/brickpool/logo/compare/v0.5.1...v0.5.2
[0.5.1]: https://github.com/brickpool/logo/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/brickpool/logo/compare/v0.4.3...v0.5.0
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Information about the API is described in the document [LOGO! Library Reference
All information about the protocols and details to the _LOGO!_ PLC are described in the associated [Wiki](http://github.com/brickpool/logo/wiki).

## Releases
The current library version is [0.5.1](https://github.com/brickpool/logo/releases). This version is not the final version, it is a release candidate, with patchlevel 1 and has implemented only the PG protocol.
The current library version is [0.5.2](https://github.com/brickpool/logo/releases). This version is not the final version, it is a release candidate and has implemented only the PG protocol.

## Examples
This directory contains the library and some examples that illustrate how the library can be used. The examples were tested with an Arduino UNO. Other hardware has not been tried.
This directory contains the library and some examples that illustrate how the library can be used. The examples were tested with an Arduino Mega (Arduino >= 1.8.5) and Arduino UNO (only Arduino 1.8.5 is supported). Other hardware has not been tried.
- [ProtocolTester.ino](/examples/ProtocolTester/ProtocolTester.ino) This example can mainly be used as a tester for the _LOGO!_ PG-protocol.
- [RunStopDemo.ino](/examples/RunStopDemo/RunStopDemo.ino) A simple program which connects to the _LOGO!_ controller and switches between the operating modes _RUN_ and _STOP_.
- [FetchDataDemo.ino](/examples/FetchDataDemo/FetchDataDemo.ino) The sample program uses the _LOGO!_ PG-protocol command _Fetch Data_.
Expand All @@ -23,10 +23,11 @@ This directory contains the library and some examples that illustrate how the li
## Dependencies
- _LOGO!_ controller version __0BA4__, __0BA5__ or __0BA6__, e.g. part number `6ED1052-1MD00-0BA6`
- _LOGO!_ PC cable, part number `6ED1057-1AA00-0BA0`
- Arduino board, e.g. [UNO](http://www.arduino.cc/)
- [Arduino board](http://www.arduino.cc/), e.g. MEGA or UNO (only Arduino 1.8.5 is supported)
- [DTE-Interface](https://github.com/brickpool/logo/wiki/DTE-Interface) for connection to the Arduino board
- Arduino Time Library [TimeLib](https://github.com/PaulStoffregen/Time)
- For the examples, the alternative SoftwareSerial library [CustomSoftwareSerial](https://github.com/ledongthuc/CustomSoftwareSerial)
- Simple application log library [ArduinoLog](https://github.com/thijse/Arduino-Log)
- Only for Arduino UNO, the alternative SoftwareSerial library [CustomSoftwareSerial](https://github.com/ledongthuc/CustomSoftwareSerial)

## License
The library is licensed under the [GNU Lesser General Public License v3.0](/LICENSE) (same as [Settimino](http://settimino.sourceforge.net/)). However, this library distributes and uses code from other Open Source Projects that have their own licenses.
Expand Down
51 changes: 40 additions & 11 deletions examples/CyclicReading/CyclicReading.ino
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
#include <CustomSoftwareSerial.h>
#ifdef ARDUINO_AVR_UNO
#if ARDUINO != 10805
#error Arduino 1.8.5 required.
#endif
#include <CustomSoftwareSerial.h>
#endif
#include <ArduinoLog.h>
#include "LogoPG.h"

const byte rxPin = 2;
const byte txPin = 3;

unsigned long cycleTime;
const unsigned long cycleDelay = 500; // min > 200ms

// set up the SoftwareSerial object
CustomSoftwareSerial LogoSerial(rxPin, txPin);
// set up the LogoSerial object
#ifdef CustomSoftwareSerial_h
#if defined(SERIAL_8E1)
#undef SERIAL_8E1
#endif
#define SERIAL_8E1 CSERIAL_8E1
#define rxPin 2
#define txPin 3
CustomSoftwareSerial LogoSerial(rxPin, txPin);
#else
// Serial1:
// rxPin 18
// txPin 19
#define LogoSerial Serial1
#endif

// set up the LogoClient object
LogoClient LOGO(&LogoSerial);

Expand All @@ -20,15 +37,24 @@ void setup() {
}

// Start the SoftwareSerial Library
LogoSerial.begin(9600, CSERIAL_8E1);
LogoSerial.begin(9600, SERIAL_8E1);
// Setup Time, 1s.
delay(1000);
Serial.println("");
Serial.println("Cable connected");
#ifdef CustomSoftwareSerial_h
if (LogoSerial.isListening())
Serial.println("Softserial is listening !");
#else
if (LogoSerial)
#endif
Serial.println("LogoSerial is ready.");

cycleTime = millis();
// LOG_LEVEL_SILENT, LOG_LEVEL_FATAL, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, LOG_LEVEL_NOTICE, LOG_LEVEL_TRACE, LOG_LEVEL_VERBOSE
// Note: if you want to fully remove all logging code, uncomment #define DISABLE_LOGGING in Logging.h
// this will significantly reduce your project size
Log.begin(LOG_LEVEL_VERBOSE, &Serial);
Log.setPrefix(printTimestamp);
}

void loop()
Expand Down Expand Up @@ -59,10 +85,8 @@ void loop()
if (millis()-cycleTime > cycleDelay)
{
cycleTime = millis();
Serial.print(cycleTime);
Serial.print("ms ");
Serial.print("POLL DATA ... ");
int Result = LOGO.ReadArea(LogoAreaDB, 1, VM_I01_08, 990-923, NULL);
Serial.print("POLL DATA ... ");
if (Result == 0)
{
Serial.print("Output 8-1, 16-9, analog input 1:");
Expand Down Expand Up @@ -118,3 +142,8 @@ void printBinaryByte(byte value)
}
}

void printTimestamp(Print* _logOutput) {
char c[12];
int m = sprintf(c, "%10lu ", millis());
_logOutput->print(c);
}
219 changes: 123 additions & 96 deletions examples/FetchDataDemo/FetchDataDemo.ino
Original file line number Diff line number Diff line change
@@ -1,97 +1,124 @@
#include <CustomSoftwareSerial.h>
#include "LogoPG.h"

const byte rxPin = 2;
const byte txPin = 3;
byte buf[1];

// set up the SoftwareSerial object
CustomSoftwareSerial LogoSerial(rxPin, txPin);
// set up the LogoClient object
LogoClient LOGO(&LogoSerial);

void setup() {
// Init Monitor interface
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// Start the SoftwareSerial Library
LogoSerial.begin(9600, CSERIAL_8E1);
// Setup Time, 1s.
delay(1000);
Serial.println("");
Serial.println("Cable connected");
if (LogoSerial.isListening())
Serial.println("Softserial is listening !");
}

void loop()
{
int Result, Status;

// Connection
while (!LOGO.Connected)
{
if (!Connect())
delay(2000);
}

Result = LOGO.GetPlcStatus(&Status);
if (Result == 0)
{
if (Status == LogoCpuStatusRun)
{
Serial.print("FETCH DATA ... ");
Result = LOGO.ReadArea(LogoAreaDB, 1, VM_Q01_08, sizeof(buf), buf);
if (Result == 0)
{
Serial.print("OK: ");
Serial.println(buf[0], HEX);
}
else
CheckError(Result);
}
else
{
Serial.println("STARTING THE PROG");
LOGO.PlcStart();
}
}
else
CheckError(Result);

delay(2000);
}

bool Connect()
{
int Result = LOGO.Connect();
Serial.println("Try to connect with LOGO");
if (Result == 0)
{
Serial.println("Connected!");
Serial.print("PDU Length = ");
Serial.println(LOGO.GetPDULength());
}
else
{
Serial.println("Connection error!");
}
return Result == 0;
}

void CheckError(int ErrNo)
{
Serial.print("Error No. 0x");
Serial.println(ErrNo, HEX);

// Checks if it's a LOGO Error => we need to disconnect
if (ErrNo & 0x01FF)
{
Serial.println("LOGO ERROR, disconnecting.");
LOGO.Disconnect();
}
}
#ifdef ARDUINO_AVR_UNO
#if ARDUINO != 10805
#error Arduino 1.8.5 required.
#endif
#include <CustomSoftwareSerial.h>
#endif
#include <ArduinoLog.h>
#include "LogoPG.h"

byte buf[2];

// set up the LogoSerial object
#ifdef CustomSoftwareSerial_h
#if defined(SERIAL_8E1)
#undef SERIAL_8E1
#endif
#define SERIAL_8E1 CSERIAL_8E1
#define rxPin 2
#define txPin 3
CustomSoftwareSerial LogoSerial(rxPin, txPin);
#else
// Serial1:
// rxPin 18
// txPin 19
#define LogoSerial Serial1
#endif

// set up the LogoClient object
LogoClient LOGO(&LogoSerial);

void setup() {
// Init Monitor interface
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// Start the SoftwareSerial Library
LogoSerial.begin(9600, SERIAL_8E1);
// Setup Time, 1s.
delay(1000);
Serial.println("");
Serial.println("Cable connected");
#ifdef CustomSoftwareSerial_h
if (LogoSerial.isListening())
#else
if (LogoSerial)
#endif
Serial.println("LogoSerial is ready.");

// LOG_LEVEL_SILENT, LOG_LEVEL_FATAL, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, LOG_LEVEL_NOTICE, LOG_LEVEL_TRACE, LOG_LEVEL_VERBOSE
// Note: if you want to fully remove all logging code, uncomment #define DISABLE_LOGGING in Logging.h
// this will significantly reduce your project size
Log.begin(LOG_LEVEL_ERROR, &Serial);
}

void loop()
{
int Result, Status;

// Connection
while (!LOGO.Connected)
{
if (!Connect())
delay(2000);
}

Result = LOGO.GetPlcStatus(&Status);
if (Result == 0)
{
if (Status == LogoCpuStatusRun)
{
Serial.print("FETCH DATA ... ");
// read first analog input
Result = LOGO.ReadArea(LogoAreaDB, 1, AI_0BA7, sizeof(buf), buf);
if (Result == 0)
{
Serial.print("OK: ");
Serial.println(LH.WordAt(buf, 0));
}
else
CheckError(Result);
}
else
{
Serial.println("STARTING THE PROG");
LOGO.PlcStart();
}
}
else
CheckError(Result);

delay(2000);
}

bool Connect()
{
int Result = LOGO.Connect();
Serial.println("Try to connect with LOGO");
if (Result == 0)
{
Serial.println("Connected!");
Serial.print("PDU Length = ");
Serial.println(LOGO.GetPDULength());
}
else
{
Serial.println("Connection error!");
}
return Result == 0;
}

void CheckError(int ErrNo)
{
Serial.print("Error No. 0x");
Serial.println(ErrNo, HEX);

// Checks if it's a LOGO Error => we need to disconnect
if (ErrNo & 0x01FF)
{
Serial.println("LOGO ERROR, disconnecting.");
LOGO.Disconnect();
}
}
Loading

0 comments on commit 75f32e8

Please sign in to comment.