Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ildefonso Martínez Marchena committed Aug 18, 2017
1 parent ba81dbf commit d22bebc
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 40 deletions.
6 changes: 3 additions & 3 deletions examples/EthernetShieldR3/EthernetShieldR3.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xAD, 0x8D };
/*
* Set your network configuration
*/
IPAddress ip(10, 0, 0, 179);
IPAddress gateway(10,0,0,1);
IPAddress dns_server(10,0,0,1);
IPAddress ip(10, 1, 0, 179);
IPAddress gateway(10,1,0,1);
IPAddress dns_server(10,1,0,1);
IPAddress subnet(255,255,255,0);

/*
Expand Down
6 changes: 3 additions & 3 deletions examples/EthernetShieldR3Random/EthernetShieldR3Random.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xAD, 0x8D };
/*
* Set your network configuration
*/
IPAddress ip(192, 168, 1, 179);
IPAddress gateway(192,168,1,1);
IPAddress dns_server(192,168,1,1);
IPAddress ip(10, 1, 0, 179);
IPAddress gateway(10,1,0,1);
IPAddress dns_server(10,1,0,1);
IPAddress subnet(255,255,255,0);

/*
Expand Down
84 changes: 50 additions & 34 deletions examples/UNO/UNO.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,82 @@

OPCSerial myArduinoUno;

opcOperation digital_status_input[14], analog_status_input[6];
opcAccessRights digital_status_input[14], analog_status_input[6];

bool readwrite_digital(const char *itemID, const opcOperation opcOP, const bool value)
{
byte port;

OPCItemType aOPCItem = myArduinoUno.getOPCItem(itemID);

port = atoi(&itemID[1]);

if (opcOP == opc_opwrite) {
if (digital_status_input[port] = opc_opread) {
digital_status_input[port] = opc_opwrite;
pinMode(port,OUTPUT);
}
if (opcOP == opc_opwrite) {
if ((aOPCItem.opcAccessRight == opc_write) || (aOPCItem.opcAccessRight == opc_readwrite)) {

digitalWrite(port,value);
if (digital_status_input[port] != opc_write) {
pinMode(port, OUTPUT);
digital_status_input[port] = opc_write;
}

digitalWrite(port,value);
}
}
else
{
if (digital_status_input[port] = opc_opwrite) {
digital_status_input[port] = opc_opread;
pinMode(port,INPUT);
}

return digitalRead(port);
}
if (opcOP == opc_opread) {
if ((aOPCItem.opcAccessRight == opc_read) || (aOPCItem.opcAccessRight == opc_readwrite)) {

if (digital_status_input[port] != opc_read) {
//pinMode(port, INPUT);
digital_status_input[port] = opc_read;
}

return digitalRead(port);
}
}
}

int readwrite_analog(const char *itemID, const opcOperation opcOP, const int value) {
byte port;

port = atoi(&itemID[1]);
int readwrite_analog(const char *itemID, const opcOperation opcOP, const int value)
{
byte port;

OPCItemType aOPCItem = myArduinoUno.getOPCItem(itemID);

port = atoi(&itemID[1]);

if (opcOP == opc_opwrite) {
if (analog_status_input[port] = opc_opread) {
analog_status_input[port] = opc_opwrite;
pinMode(port,OUTPUT);
if ((aOPCItem.opcAccessRight == opc_write) || (aOPCItem.opcAccessRight == opc_readwrite)) {

if (analog_status_input[port] != opc_write) {
pinMode(port, OUTPUT);
analog_status_input[port] = opc_write;
}

analogWrite(port,value);
}

digitalWrite(port,value);
}
else
{
if (analog_status_input[port] = opc_opwrite) {
analog_status_input[port] = opc_opread;
pinMode(port,INPUT);
}

return analogRead(port);
}
if (opcOP == opc_opread) {
if ((aOPCItem.opcAccessRight == opc_read) || (aOPCItem.opcAccessRight == opc_readwrite)) {

if (analog_status_input[port] != opc_read) {
//pinMode(port, INPUT);
analog_status_input[port] = opc_read;
}

return analogRead(port);
}
}

}

void setup() {
byte k;

Serial.begin(9600);

for (k=0;k<14;k++) digital_status_input[k] = opc_opread;
for (k=0;k<5;k++) analog_status_input[k] = opc_opread;
for (k=0;k<14;k++) digital_status_input[k] = opc_undefined;
for (k=0;k<5;k++) analog_status_input[k] = opc_undefined;

myArduinoUno.setup();
myArduinoUno.addItem("D0",opc_readwrite, opc_bool, readwrite_digital);
Expand Down

0 comments on commit d22bebc

Please sign in to comment.