int main(int argc, const char **argv) { SerialPortalIndication indication(IfcNames_SerialPortalIndicationH2S); EchoRequest echo(IfcNames_EchoRequestH2S); Simple simple(IfcNames_SimpleRequestH2S); SerialPortalRequestProxy *device = new SerialPortalRequestProxy(IfcNames_SerialPortalRequestS2H); EchoIndicationProxy *echoIndication = new EchoIndicationProxy(IfcNames_EchoIndicationS2H); SimpleRequestProxy *simpleRequest = new SimpleRequestProxy(IfcNames_SimpleRequestS2H); if (!argv[1]) { //realpath("/sys/class/tty/ttyUSB0/device/driver/"); fprintf(stderr, "usage: %s /dev/ttyUSBn\n", argv[0]); return -EINVAL; } int serial_fd = initSerial(argv[1]); PortalSharedParam paramSerial; paramSerial.serial.serial_fd = serial_fd; Portal *mcommon = new Portal(0, 0, sizeof(uint32_t), portal_serialmux_handler, NULL, &transportSerial, ¶mSerial, 0); PortalMuxParam param = {}; param.pint = &mcommon->pint; EchoRequestProxy echoSerial(0, &transportSerialMux, ¶m); SimpleRequestProxy simpleSerial(1, &transportSerialMux, ¶m); EchoIndication serialEchoIndication(0, &transportSerialMux, ¶m); Simple serialSimple(1, &transportSerialMux, ¶m); device->setDivisor(134); sleep(2); echoSerial.say(0x6789); echoSerial.say2(0x22, 0x23); sleep(2); simpleSerial.say1(v1a); simpleSerial.say2(v2a, v2b); sleep(2); echoIndication->heard2(0x68,0x47); echoIndication->heard(0x22); sleep(2); simpleRequest->say1(19); while (1) { // wait } }
int main(int argc, const char **argv) { SimpleIndication *indication = new SimpleIndication(IfcNames_SimpleIndication); SimpleRequestProxy *device = new SimpleRequestProxy(IfcNames_SimpleRequest); fprintf(stderr, "Main::creating exec thread\n"); portalExec_start(); fprintf(stderr, "Main::calling say1(%d)\n", v1a); device->say1(v1a); fprintf(stderr, "Main::calling say2(%d, %d)\n", v2a,v2b); device->say2(v2a,v2b); fprintf(stderr, "Main::about to go to sleep\n"); sleep(5); exit(0); }