Author Topic: Two-Way Communication - CDC  (Read 10906 times)

nic.ashby

  • Newbie
  • *
  • Posts: 17
Two-Way Communication - CDC
« on: June 20, 2015, 02:30:14 pm »
I am able to send to the digispark; the CDCLED sketch works.
I am unable to receive, however; I get nothing back using the Echo sketch.
Using Ubuntu.
Any suggestions?

Zitt

  • Newbie
  • *
  • Posts: 4
DigiCDC Serial returns no data
« Reply #1 on: July 20, 2015, 10:28:42 pm »
I recently upgraded from the DigiSpark to the Pro because I needed more memory for the USB serial implementation. The normal 8k just won't work. I've had a whole slew of problems "porting" my existing DigiSpark to the Pro... but more on that in a separate thread.

I went back to basics and tried the Echo from DigisparkCDC  example. It doesn't work. I can't get anything to echo back using the serial monitor or the COM port using a terminal.

The CDC_LED does work; IE sending 0 or 1 to the port turns off/on the LED. So; I went and added a simple:
SerialUSB.println("LED off");
to the project and while the LED still occurs; it WILL NO transmit data back to me.

What's the deal here? Is the CDC sample code broken on the pro?!

Here's the complete project:

#include <DigiCDC.h>
void setup() {               
  // initialize the digital pin as an output.
  SerialUSB.begin();
  pinMode(1,OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
 
  //turns led on and off based on sending 0 or 1 from serial terminal
  if (SerialUSB.available()) {
    char input = SerialUSB.read();
    if(input == '0') {
      digitalWrite(1,LOW);
      SerialUSB.println("LED off");
    } 
    else if(input == '1') {
      digitalWrite(1,HIGH);
      SerialUSB.println("LED ON");
    } 
     
  }
 
   SerialUSB.delay(100);               // keep usb alive // can alos use SerialUSB.refresh();
}

Zitt

  • Newbie
  • *
  • Posts: 4
Re: Two-Way Communication - CDC
« Reply #2 on: July 20, 2015, 10:59:09 pm »
Same problem; on windows.
So this looks to be a major bug with the Pro which they haven't bothered to fix.

Zitt

  • Newbie
  • *
  • Posts: 4
Re: Two-Way Communication - CDC
« Reply #3 on: July 21, 2015, 07:40:22 pm »
Just forget DigiCDC. i dont't think it will ever be reliable. Use either DigiUSB or an USB-serial chip like FT 232 or CP2102 or PL2303, or take an Arduino Leonardo or Arduino Micro (they use an AtMega32A4 which has a hardware USB port and emulates serial communication much better).

No, this is a "Feature" of the digistump product - like it or not.
I expect them to fix their projects. It works very reliably on the non-Pro - so they need to spend some time fixing the code to work on the pro.

nic.ashby

  • Newbie
  • *
  • Posts: 17
Re: DigiCDC Serial returns no data
« Reply #4 on: July 26, 2015, 08:54:40 pm »
Having this same problem.

nic.ashby

  • Newbie
  • *
  • Posts: 17
Re: Two-Way Communication - CDC
« Reply #5 on: July 30, 2015, 09:51:30 pm »
Not sure that I should be forgetting about the new library for the old discontinued library.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Two-Way Communication - CDC
« Reply #6 on: August 04, 2015, 12:19:42 pm »
I've merged the two topics about this, into one.

While I wouldn't agree you should forget DigiCDC, DigiUSB is more standards compliant, so you may have better luck with it.

Ultimately all Digispark USB functions are hacks - that was the original premise of the Digispark design, implementing USB in software only to make a low cost device. That said, DigiCDC does work on most machines and running systems - but it does not work on everything because low speed serial is not standards compliant. We're pretty confident (with hundreds of hours in it, and dozens of test machines, not to mention thousands of users) that it is as reliable/working as it can be - so if it isn't working for you with the Echo demo (and you are using the newest version!) my suggestions would be:

1. Try another computer and/or USB port, cable or hub.

2. After uploading, remove and reattach the Digispark, wait for it to enumerate as a Serial device and then open the serial monitor. Sometimes forcing the remuneration helps.

3. Try a different operating system (and please reply with what system you are using).

4. Try DigiUSB, if it will work for your application.

Out of all my test machines it works on all but one, however, like the Digispark bootloader - it does not work on all port/hubs/cables I have and seems to be a bit more sensitive about that. In addition various versions of Linux, Windows 8, and OS X work with different levels of reliability (as Ralf notes).

Just to be sure nothing magically broke since my last tests - I just loaded Echo unmodified from the 1.6.5 board manager install and it did work for me without issue (Win7 x64) on the computer I'm on right now - please let me know what OS and version you two are running, so I can test more specifically.

Thanks,
Erik


Zitt

  • Newbie
  • *
  • Posts: 4
Re: Two-Way Communication - CDC
« Reply #7 on: August 04, 2015, 04:15:50 pm »
Win7 x64bit here
Also tried in win10 x32 netbook
Both times the transmit seems to work from host to uC... but doesn't work other dir

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Two-Way Communication - CDC
« Reply #8 on: August 04, 2015, 08:41:14 pm »
Well the use of it on a win7 x64 seems to rule out OS

Can you try it with one of your Digisparks (not Pro) - or a second Pro?

I imagine you don't but just to be sure - do you have anything attached to pins 3 and 4?

Given it works in one direction - I don't think it is a cable, hub, etc issue.

Can you add the blinking of the LED to your echo sketch and see if it stops blinking at any time or if it is constant?

I'm a bit stumped - the issues I've seen have all been it just plain doesn't work - or it fails after X characters are sent or received (buffer/timing issues)


magnets

  • Newbie
  • *
  • Posts: 6
Re: Two-Way Communication - CDC
« Reply #9 on: August 15, 2015, 05:18:00 pm »
possibly not related, but a lot of my older stuff won't work on usb 3 ports.
i either have to use a usb2 port or a hub in between.

i've not tried cdc so this might be a red herring but it's another variable to twiddle.

also, vm's can introduce issues too. so native is should be the primary test environment.