Usb serial module Tx

Hello!

A few weeks ago, I had implemented a usb serial module into my program and
it worked ok (able to receive and transmit and talk to a terminal program running
on a pc).

Today, I notice that it can receive ok from the terminal program, however, when I transmit
back to the terminal program, I am not getting anything.

I notice that when I transmit from the pc terminal to the usb serial module, as soon as
my function is called to receive data (catching the event Serial.LineReceivedEventHandler),
I see the TX led on the usb serial module flash red.

What does this led mean?
ie - Does that mean I received data (normal) or does it mean there is an error?

As mentioned, I do receive the data ok, but when I transmit a reply back, I get nothing on
the terminal and also I don’t see any led’s on the serial module flash. The function to write executes w/o any exceptions, and as I mentioned before, this code worked a few weeks ago so I suspect my usb-serial module has a problem. I am re-ordering one so I can verify that, but just posting in case someone has some other idea.

also, I changed cables but same result. Here is the code:

void initSerialInterface()
{
usbSerial.Configure(115200,
GT.Interfaces.Serial.SerialParity.None,
GT.Interfaces.Serial.SerialStopBits.One,
8);

       GT.Interfaces.Serial.DataReceivedEventHandler(SerialLine_DataReceived);
        usbSerial.SerialLine.Open();
        usbSerial.SerialLine.LineReceivedEventDelimiter = "\r";
        usbSerial.SerialLine.LineReceived += new     GT.Interfaces.Serial.LineReceivedEventHandler(SerialLine_DataReceived);
    }

void SerialLine_DataReceived(GT.Interfaces.Serial sender, string data)
{
// this is my breakpt and I see the tx led flash red when it stops here
//then I step over this next line but receive nothing, but it used to work ok…
usbSerial.SerialLine.WriteLine(data);

    }

Even I’m a newbie and working on same thing…
please check this article… It might help your case…

https://www.ghielectronics.com/docs/97/usb-serial-module#951

Hi sri1729,

thanks, but I was already aware of that document.
That document helped me create the code a few weeks ago, but it doesn’t help
solve my current issue.

My code was working before, but now stopped working, maybe it is hardware.

Ive seen issues with line received before.
try using usbSerial.SerialLine.DataReceived that will allow you to at least see if you are getting some data which you can delve into to get an idea.
If the LineReceived event isn’t firing it could just mean its not getting the delimiter. Also try reducing the Baud rate on both the PC and in the code.

Hi Hugh,

thanks for your reply, but I think you guys don’t understand my problem.

I have no trouble receiving data via the event.

My problem is that when I try to send data back to the terminal, the terminal is not
seeing anything. (I tried both with and without the delimeter). The terminal program
shows nothing was received.

As I mentioned, everything worked ok a few weeks ago - was able to receive and transmit back -

But now, I can only receive data from the terminal but cannot transmit anything back.
I have ordered another usb-serial module so will see if by plugging in a new one, will it work.

I already tried switching cables but it is no difference…
I was hoping someone from GHI could tell me if I should expect the usb-serial module Rx or Tx led to come on
whenever I transmit back.

Right now, when I send data from the terminal to the spider, I see the Tx led flash and then then I receive the data. When I send data back, I see no led flash (neither rx or tx).

I’m guessing I should see something, so I’m guessing the module is not working correctly since it is the same code as before. But would be nice to know if led’s should come on or not…

Hi,
did you try to deinstall the virtual Com ports in device manger and and so force Windows to reinstall the virtual Com ports on your PC. Sometimes there are hidden und unusabel Com Ports that “are broken” and should be deinstalled as well. I hat some Trouble with those issues when I used virtual Com Ports for a Bluetooth Connection.
Cheers
Roland

Hi RoSchmi,

Thanks for the advise -

I uninstalled and re-installed as you suggested but it didn’t work.

It was a good idea, but unfortunately, did not help in this situation.

thanks,

David

Ok what happens if you start a new gadgeteer project and just send strings out to the PC? Put it in a timed event with a button to start and stop it.
Do you see any data received at the PC?

Also try converting the data to a string and then write the string back out the serial port.

Thanks for the good idea Hugh -

I created a complete new project from scratch, but still don’t see any data at the pc.

I tried a few things -

  1. put in a button to just write a string whenever I press it and also write a string
    to Debug so I can tell the button is getting called. I see the button is called but do
    not see anything sent out to the terminal.

  2. put in a timer which prints a string every 500 ms whenever it is started,
    but still see nothing.

  3. then put in the function to call whenever data is received from the terminal.
    again, that works ok - so still able to receive data but cannot send it.

Still would like to know what I should see on the usb serial module when data is
Transmitted and received.

It seems strange to me, but whenever the module receives data (ie from the pc), the Tx led flashes. (seems it should be the Rx led)
But when I send out data, neither of the led’s flash —> my question is should one of these led’s flash when data goes out???

anyway, thanks again for the good idea but looks like no answers yet. I will be out a few
days so will try this again next week. I should receive a new usb serial module by then, so hopefully the new one works…

I often try to go back to first principles here when I get a weird error like this.

Can I get TX and RX connected to each other from the mainboard (use a jumper on an Extender module or G-Plug), and am I then getting data in my app at both ends.

Can I get TX and RX connected to each other from the Serial-USB module (ditto on jumper) and does a character get echoed from the PC in the terminal.

Can I swap as many cables as are in the setup to see if that changes the behavior

… I know none of that helps answer your question about “should the LED”… but at least it’ll still give you scope to move forward in your troubleshooting. And like everything, yes it could be a failure, but I wouldn’t put my money on it just yet…

You should see the led flash (tx or rx) when data passes. Let us know what the new usb serial module does. It may be that the one you have has gone bad.
If i get a chance i will take a look at mine.

Here is an update on my situation:

I came in today and I had to move my setup to another desk nearby, but still using
the same computer and same usb connections.

I powered it on and everything works now!

And, now I see both the rx and tx led flash.
Here is what happens -
when I send down data from the computer, the tx flashes red.
Then when data goes back from the spider to the computer, the
rx flashes green.

I think maybe because I physically disconnected the usb cable from the computer to
the module , then plugged back in - perhaps that somehow caused it to start working.

Before, I had reinstalled the drivers and rebooted the computer but I didn’t actually disconnect the cable. Maybe that was the key…

I haven’t received the new module yet but should get it soon.
I guess for now, it works…

just to clarify, of course, before I had unplugged the cable from the module last week but
still was not working.

but today I unplugged the cable from the computer usb port when I moved it.

that is the only difference besides also picking up all the components and moving to
another location…

Good news :slight_smile: Glad you got it working

Now, it quit working again.

It was working for about a week, now today stopped working.

I re-installed the drivers again, removed the cable, etc.
Plus tried a different usb serial module, different cables, but it is the old problem again
where I can transmit but cannot receive.

I have ordered a new spider mainboard as I’m wondering now if this
is a board has some problems…

Probably, for my project, I will not be able to rely on usb-serial. I guess I have to
use ethernet which seemed to work better but is really over-kill for what I want.

I wish the usb-serial module and the sd card module would just work - that would be nice…

Personal conjecture: the USB-Serial module should just work. It’s not hard. Buy yourself a handful of the CP2102 USB to TTL UART modules on ebay for virtually no cash (a tenner should get you 4, delivered), and see if that behaves differently or not. It’s just a UART so code wise should be no different.

Remember the old jumper-between-tx-and-rx trick. If you send stuff, you will get it back if the rx is working. Also remember to have a simple test app that just does this, so you don’t have to question whether you have mucked up something in your larger project.

SD cards on the other hand, are not quite so simple, agreed… although they should be :frowning:

Perhaps it’s worth a try to run the PC application in another user account of your PC or to try if it works on another PC perhaps with another Windows Version. I would suspect that the problem with the usb serial module is on the PC-side of the connection.

For the SD-Card issue I would also try to change the SD-Card module.

Did you consider to use Bluetooth as data connection?

Cheers
Roland

ok Brett & RoSchmi -

thanks for the advice, I’ll see what I can do and update later…

RoSchmi - as to the SDCard, I have asked previously does anyone
know of a particular sdcard that does work on the spider sdcard module.

I have already tried 2 different cards, one an 8gig Sandisk and one is a 4 gig
Samsung but same problem on both.

thanks,

David

Hi,
you told that the program already crashed in this line

this.sdCard = new GTM.GHIElectronics.SDCard(5);

I never saw this on Spider with the SD-Card module, not even when there were write problems with a special SD-Card. So I think that it might be that not the SD-Card but the SD-Card module is the reason.

Hi RoSchmi,

That is true, but keep in mind it only crashes if there is a card inside.

If no card is present, then it does not bomb on that line. I guess I could consider getting
another sd card module…

Also regarding the usb to serial module, Brett was mentioning to try this usb to uart test, and I will consider that, however, I doubt it is the usb because I’m able to use it to load and get files from a usb stick w/o problems.

Also, I am able to transmit from the computer to the spider and receive the message on the spider. But, when the spider tries to send back a message, the led does not light up, so
it makes me think the problem is on the usb-serial module and not my computer.

(when it was working, the led on the module lights up whenever a message goes back
to the computer.

thanks,

David