[EthercatDevice_QECRXXHU]
Description
Slave SDO data exchange function.
Class Modules
class EthercatDevice_QECR11HU5S; /* MPG + Keypad + LCM + RS232x2, RJ45 power [1, 1] */ class EthercatDevice_QECR00HU5S; /* MPG + Keypad + LCM + RS232x2, RJ45 power [0, 0] */ class EthercatDevice_QECR11HU9S; /* MPG + Keypad + LCM + RS232/485x2, RJ45 power [1, 1] */ class EthercatDevice_QECR00HU9S; /* MPG + Keypad + LCM + RS232/485x2, RJ45 power [0, 0] */
Format
int update();
Syntax
EthercatDevice_QECRXXHU slave;
slave.update();
Returns
Int: 0 for successful; if the return value is smaller than 0 means an error.
Example
#include "lvgl86.h" #include "ECBarCode.h" EthercatMaster EcatMaster; EthercatDevice_QECR11HU5S Slave; MyEVASerial SerialEVA1; MyEVASerial SerialEVA2; BarcodeScanner BARCODE1; BarcodeScanner BARCODE2; unsigned char state = 0; void btn1_event_cb(lv_obj_t* obj, lv_event_t e) { if (e == LV_EVENT_CLICKED) state |= 0x01; } void btn2_event_cb(lv_obj_t* obj, lv_event_t e) { if (e == LV_EVENT_CLICKED) state |= 0x02; } void btn3_event_cb(lv_obj_t* obj, lv_event_t e) { if (e == LV_EVENT_CLICKED) { BARCODE1.stopScan(); BARCODE2.stopScan(); state = 0; } } void setup() { lv86_init(); Serial.begin(115200); EcatMaster.begin(ECAT_ETH_0, NULL); Slave.attach(0, EcatMaster, ECAT_SLAVE_NO); EcatMaster.start(); SerialEVA1.init(&Slave, COM1); SerialEVA1.begin(115200); SerialEVA2.init(&Slave, COM2); SerialEVA2.begin(115200); if (!BARCODE1.begin(HONEYWELL_N4680, &SerialEVA1)) Serial.println("BARCODE1 begin() is fail"); else Serial.println("BARCODE1 begin() OK!"); if (!BARCODE2.begin(HONEYWELL_N4680, &SerialEVA2)) Serial.println("BARCODE2 begin() is fail"); else Serial.println("BARCODE2 begin() OK!"); // UI console.beginEX(0x7878D0, 600, 450, 20, 20); lv_obj_t* btn1 = lv_btn_create(lv_scr_act(), NULL); lv_obj_set_size(btn1, 100, 40); lv_obj_t* label1 = lv_label_create(btn1, NULL); lv_label_set_text(label1, "Scan1"); lv_obj_align(btn1, NULL, LV_ALIGN_IN_TOP_LEFT, 650, 50); lv_obj_set_event_cb(btn1, btn1_event_cb); lv_obj_t* btn2 = lv_btn_create(lv_scr_act(), NULL); lv_obj_set_size(btn2, 100, 40); lv_obj_t* label2 = lv_label_create(btn2, NULL); lv_label_set_text(label2, "Scan2"); lv_obj_align(btn2, NULL, LV_ALIGN_IN_TOP_LEFT, 650, 120); lv_obj_set_event_cb(btn2, btn2_event_cb); lv_obj_t* btn3 = lv_btn_create(lv_scr_act(), NULL); lv_obj_set_size(btn3, 100, 40); lv_obj_t* label3 = lv_label_create(btn3, NULL); lv_label_set_text(label3, "Stop"); lv_obj_align(btn3, NULL, LV_ALIGN_IN_TOP_LEFT, 650, 190); lv_obj_set_event_cb(btn3, btn3_event_cb); } void loop() { if ((state & 0x01) > 0) { if (BARCODE1.available() != 0) { char* tmp = BARCODE1.readLine(); if (tmp != NULL) { console.println(tmp); state &= 0xFE; } } } if ((state & 0x02) > 0) { if (BARCODE2.available() != 0) { char* tmp = BARCODE2.readLine(); if (tmp != NULL) { console.println(tmp); state &= 0xFD; } } } Slave.update(); lv_task_handler(); }
Libraries Reference Home
The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.