Author Topic: TTL Serial connection  (Read 695 times)

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
TTL Serial connection
« on: August 12, 2017, 09:03:25 am »
I have a USB TTL device that connects to my mac with this address:

Code: [Select]
/dev/cu.usbmodem1421
I am trying to connect to it using the Develop Apps -> Serial Port Configuration but it is not identified by my Vera... I suppose it is looking for FTDI Serial devices, or may I connect TTL devices?

how may i accomplish this or will I need a FTDI to TTL converter?

Offline Z-Waver

  • Master Member
  • *******
  • Posts: 4431
  • Karma: +247/-120
Re: TTL Serial connection
« Reply #1 on: August 13, 2017, 12:32:10 pm »
SSH into Vera and run dmesg. Note the last couple of lines.

Plug the device into Vera and then run dmesg again. Find the previously noted last couple of lines. Anything after those lines is related to the newly plugged device, including its path /dev/...

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: TTL Serial connection
« Reply #2 on: August 14, 2017, 09:02:27 am »
OK, progress... Thanks!!

without USB device:
Code: [Select]
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
eth0: link down
eth0: link up (100Mbps/Full duplex)
ramips-wdt: timeout value 60 must be 0 < timeout < 25
eth0: link down
eth0: link up (100Mbps/Full duplex)
eth0: link down
eth0: link up (100Mbps/Full duplex)

and with USB device attached:
Code: [Select]
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
eth0: link down
eth0: link up (100Mbps/Full duplex)
ramips-wdt: timeout value 60 must be 0 < timeout < 25
eth0: link down
eth0: link up (100Mbps/Full duplex)
eth0: link down
eth0: link up (100Mbps/Full duplex)
usb 2-1: new full speed USB device using rt3883-ohci and address 2
cdc_acm 2-1:1.0: This device cannot do calls on its own. It is not a modem.
cdc_acm 2-1:1.0: ttyACM0: USB ACM device

What to do next?

Offline Z-Waver

  • Master Member
  • *******
  • Posts: 4431
  • Karma: +247/-120
Re: TTL Serial connection
« Reply #3 on: August 15, 2017, 07:46:08 am »
/dev/ttyACM0 its your device.

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: TTL Serial connection
« Reply #4 on: August 15, 2017, 08:43:01 am »
/dev/ttyACM0 its your device.

so, i can disregard this message:
Code: [Select]
cdc_acm 2-1:1.0: This device cannot do calls on its own. It is not a modem.
?

Offline Z-Waver

  • Master Member
  • *******
  • Posts: 4431
  • Karma: +247/-120
Re: TTL Serial connection
« Reply #5 on: August 16, 2017, 08:32:11 am »
I don't know.

All I can tell you is that when plugged into Vera, the device exists at /dev/ttyACM0


Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: Serial Plugin
« Reply #6 on: August 22, 2017, 11:10:33 pm »
So I added an FTDI USB serial chip to my rig and I can now see it
.

I'm using Florin's simple serial plugin and I can send a message to my Serial device, which simply echo's it back.

Echo C++ code:

Code: [Select]
const size_t MAX_MESSAGE_LENGTH = 32;

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  if(char* newMessage = checkForNewMessage(Serial, '\n'))
  {
    Serial.println(newMessage);
  }
}

char* checkForNewMessage(Stream& stream, const char endMarker)
{
  static char incomingMessage[MAX_MESSAGE_LENGTH] = "";
  static byte idx = 0;
  if(stream.available())
  {
    incomingMessage[idx] = stream.read();
    if(incomingMessage[idx] == endMarker)
    {
      incomingMessage[idx] = '\0';
      idx = 0;
      return incomingMessage;
    }
    else
    {
      idx++;
      if(idx > MAX_MESSAGE_LENGTH - 1)
      {
        stream.print(F("{\"error\":\"message too long\"}\n"));  //you can send an error to sender here
        idx = 0;
        incomingMessage[idx] = '\0';
      }
    }
  }
  return NULL;
}

Code: [Select]
08 08/22/17 23:00:24.396 JobHandler_LuaUPnP::HandleActionRequest device: 233 service: urn:micasaverde-com:serviceId:SimpleSerial1 action: Send <0x2f238680>
08 08/22/17 23:00:24.397 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=233 <0x2f238680>
08 08/22/17 23:00:24.397 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:SimpleSerial1 <0x2f238680>
08 08/22/17 23:00:24.398 JobHandler_LuaUPnP::HandleActionRequest argument action=Send <0x2f238680>
08 08/22/17 23:00:24.398 JobHandler_LuaUPnP::HandleActionRequest argument Message=testing <0x2f238680>
50 08/22/17 23:00:24.399 luup_log:233: Send: 'testing' <0x2f238680>
50 08/22/17 23:00:24.408 luup_log:233: Received: 'testing' <0x2dc31680>
06 08/22/17 23:00:24.408 Device_Variable::m_szValue_set device: 233 service: urn:micasaverde-com:serviceId:SimpleSerial1 variable: Received was: no message received now: testing #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x2dc31680>

but I have this error on the device...

Code: [Select]
Can't Detect Device

I'm wondering if it is a UI7 issue...

Any assistance is appreciated!

« Last Edit: August 22, 2017, 11:12:19 pm by BulldogLowell »

Offline akbooer

  • Master Member
  • *******
  • Posts: 5283
  • Karma: +229/-67
  • "Less is more"
Re: TTL Serial connection
« Reply #7 on: August 23, 2017, 02:50:34 am »
Almost definitely UI7...

Vera, unwisely, changed the syntax and impact of the luup.set_failure() call.  It may be this, or the lack of it, which causes the problem.  It may also be the parameter(s) returned by the plugin init funcion.

I haven't looked at the code, but I would start with the above.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: TTL Serial connection
« Reply #8 on: August 23, 2017, 09:57:22 am »
Vera, unwisely, changed the syntax and impact of the luup.set_failure() call.  It may be this, or the lack of it, which causes the problem.  It may also be the parameter(s) returned by the plugin init funcion.

Thanks, that did it!