You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
/*
|
|
* goose_publisher_example.c
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#include "mms_value.h"
|
|
#include "goose_publisher.h"
|
|
|
|
// has to be executed as root!
|
|
int
|
|
main(int argc, char** argv)
|
|
{
|
|
|
|
LinkedList dataSetValues = LinkedList_create();
|
|
|
|
LinkedList_add(dataSetValues, MmsValue_newIntegerFromInt32(1234));
|
|
LinkedList_add(dataSetValues, MmsValue_newBinaryTime(false));
|
|
LinkedList_add(dataSetValues, MmsValue_newIntegerFromInt32(5678));
|
|
|
|
CommParameters gooseCommParameters;
|
|
|
|
gooseCommParameters.appId = 1000;
|
|
gooseCommParameters.dstAddress[0] = 0x01;
|
|
gooseCommParameters.dstAddress[1] = 0x0c;
|
|
gooseCommParameters.dstAddress[2] = 0xcd;
|
|
gooseCommParameters.dstAddress[3] = 0x01;
|
|
gooseCommParameters.dstAddress[4] = 0x00;
|
|
gooseCommParameters.dstAddress[5] = 0x01;
|
|
gooseCommParameters.vlanId = 0;
|
|
gooseCommParameters.vlanPriority = 4;
|
|
|
|
GoosePublisher publisher = GoosePublisher_create(&gooseCommParameters, "eth0");
|
|
|
|
GoosePublisher_setGoCbRef(publisher, "simpleIOGenericIO/LLN0$GO$gcbAnalogValues");
|
|
GoosePublisher_setConfRev(publisher, 1);
|
|
GoosePublisher_setDataSetRef(publisher, "simpleIOGenericIO/LLN0$AnalogValues");
|
|
|
|
int i = 0;
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
sleep(1);
|
|
|
|
if (GoosePublisher_publish(publisher, dataSetValues) == -1) {
|
|
printf("Error sending message!\n");
|
|
}
|
|
}
|
|
|
|
GoosePublisher_destroy(publisher);
|
|
}
|
|
|
|
|
|
|
|
|