UART Communication TX

144 views
Skip to first unread message

sheershak agarwal

unread,
May 17, 2021, 4:32:23 PM5/17/21
to F´ Community Group
Hi,

I am trying to talk to an Arduino using the UART protocol. I am able to successfully read the data from Arduino but unable to send the text to it. In my Top Topology ,  I have the following connections for UART

<!-- GPS  Connections
    Here we add the connections that aren't part of standard connection patterns, namely we attach the serial ports to
    the Gps and to drivers.
    -->
    <connection name = "uartIn">
        <source component = "gpsSerial" port = "serialRecv" type = "Drv::SerialRead" num = "0"/>
        <target component = "gps" port = "serialRecv" type = "Drv::SerialRead" num = "0"/>
    </connection>
    <connection name = "uartOut">
        <source component = "gpsSerial" port = "serialSend" type = "Drv::SerialWrite" num = "0"/>
        <target component = "gps" port = "serialSend" type = "Drv::SerialWrite" num = "0"/>
    </connection>
    <connection name = "uartBuff">
        <source component = "gps" port = "serialBufferOut" type = "Drv::BufferSend" num = "0"/>
        <target component = "gpsSerial" port = "readBufferSend" type = "Drv::BufferSend" num = "0"/>
    </connection>


but I am getting an error 
build-fprime-automatic-native/App/Top/AppTopologyAppAc.cpp:200:15: error: ‘class Drv::LinuxSerialDriverComponentImpl’ has no member named ‘set_serialSend_OutputPort’; did you mean ‘set_serialRecv_OutputPort’?
     gpsSerial.set_serialSend_OutputPort(0, gps.get_serialSend_InputPort(0));
               ^~~~~~~~~~~~~~~~~~~~~~~~~
               set_serialRecv_OutputPort
/home/sheershak/F-Prime/App/build-fprime-automatic-native/App/Top/AppTopologyAppAc.cpp:200:48: error: ‘class App::GpsComponentImpl’ has no member named ‘get_serialSend_InputPort’; did you mean ‘get_serialRecv_InputPort’?
     gpsSerial.set_serialSend_OutputPort(0, gps.get_serialSend_InputPort(0));
                                                ^~~~~~~~~~~~~~~~~~~~~~~~

which essententially means that the gpsSerial module doesn't have serialSend Port but I crosschecked and both the modules have serialSend Port initialized. Am I missing something?

lestarch

unread,
May 17, 2021, 5:50:25 PM5/17/21
to F´ Community Group
What version of F´ are you working off from?  Are you following along with the gps tutorial or referencing some other code?  Are you compiling for Linux or something else?

-Michael

sheershak agarwal

unread,
May 18, 2021, 11:17:55 AM5/18/21
to F´ Community Group
I am using the latest version of F'. Yes I followed the GPS tutorial and also refencing the Rpi Demo for SerialWrite. Yes I am compiling on Linux.

lestarch

unread,
May 18, 2021, 2:01:31 PM5/18/21
to F´ Community Group
Ok.  I'll try to take a look.  I agree with you that this should work, so I am unclear what is wrong.

-Michael

sheershak agarwal

unread,
May 21, 2021, 11:41:15 AM5/21/21
to F´ Community Group
Hi, I was able to fix the error but something new popped up. Whenever I transmit from  UART port for the first time, it runs without any problem but doesn't give me a output on the logic analyzer. When I transmit the data second time, it throws a FATAL error in LinuxSerialDriver Assert OS.queue status.

The code for send TX:

char text[50];
sprintf(text, "%s %d", "APPROXPOSTIMEOUT", 10);
U8* pointer = reinterpret_cast<U8*>(text);
int count = 0;
    for(int i = 0; text[i] != '\0'; i++){
      count++;
}
printf("%s %d\n",pointer,count);

    Fw::Buffer txt;
    txt.setSize(count);
    txt.setData(pointer);
    this->UartWrite_out(0,txt);

 log_ACTIVITY_HI_GPS_OPERATION_PERFORMED();


The error I am receiving on the second transmit:

Assert in file /home/sheershak/F-Prime/App/build-fprime-automatic-native/F-Prime/Drv/LinuxSerialDriverComponentAc.cpp, line 1495: 8

which is 

  FW_ASSERT(
        qStatus == Os::Queue::QUEUE_OK,
        static_cast<AssertArg>(qStatus)
    );

Can you please explain why I am not receiving any data on my receive end and why does it throw the error on the second attempt? Could you also provide a solution?

Thanks

Michael Starch

unread,
May 27, 2021, 11:32:31 AM5/27/21
to sheershak agarwal, F´ Community Group
Some things to check:

1. UartWrite is wired to an instance of  the Linux Serial driver in your topology
2. Has the Linux Serial Driver been "started" with the start method in the topology?  Has it been "opened" in the topology?

If you can send the Topology snippet, I can take a look to see if there is anything obvious.

Other (possible)  issues:

1.  If you are running on an RPI, did you configure the serial port to be enabled?
2. On Linux does your user have serial port permissions?
3. Does another process own the serial port device?

-Michael

--
You received this message because you are subscribed to the Google Groups "F´ Community Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fprime-communi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fprime-community/16e64447-79a0-434c-9317-d52744af18c9n%40googlegroups.com.

Grant Gunnison

unread,
May 28, 2021, 11:34:38 AM5/28/21
to F´ Community Group
Michael here is the Topology file that we are using. Let us know if there is anything you see here that could be problematic!


Thanks :)

Topology.cpp

sheershak agarwal

unread,
May 31, 2021, 10:32:46 AM5/31/21
to F´ Community Group
Hi Michael,

Would it possible to get some personal support for our project since we are on a hard deadline. I would be able to provide you the access to our github repo and we can setup some time to talk about the problems and possible solutions. Let me know your thoughts on this.

sheershak agarwal

unread,
May 31, 2021, 11:23:12 AM5/31/21
to F´ Community Group

Nathan Cheek

unread,
Jun 1, 2021, 4:46:46 AM6/1/21
to sheershak agarwal, F´ Community Group
Can you provide more context around the asserting line? What is the function in LinuxSerialDriverComponentAc.cpp that asserts? Can you determine the call stack, i.e. what is the order of function calls that gets us to this call to FW_ASSERT?

A value of 8 seems to imply a QUEUE_FULL error. My hunch is that something isn't getting taken out of the queue the first attempted "transmit", so during the second attempted "transmit", the queue is full. But it would be easier to diagnose if you can figure out what queue is prompting this error.

On Fri, May 21, 2021 at 8:41 AM sheershak agarwal <sheer...@gmail.com> wrote:

lestarch

unread,
Jun 2, 2021, 12:19:06 AM6/2/21
to F´ Community Group
You are getting a queue overflow (or at least that is what assert with argument 8 usually means).  This means that a queue you are sending messages to is not being processed fast enough and it overflows.  However, I am also noticing that the line number of your assert is past the end of the file (when I build)....so I cannot determine which port is overflowing.

   Assert in file /home/sheershak/F-Prime/App/build-fprime-automatic-native/F-Prime/Drv/LinuxSerialDriverComponentAc.cpp, line 1495: 8

My file is only 1395 lines long....which is confusing. Doubly confusing is that the LinuxSerialDriver is a passive component, so it shouldn't have a queue.  To help further I'd need to see the whole file that is asserting.

-Michael

lestarch

unread,
Jun 2, 2021, 12:22:06 AM6/2/21
to F´ Community Group
Just out of curiosity, have you modified the "LinuxSerialDriver" component at all?  Have you removed your build cache and regenerated, then built lately?  Something odd is happening.

-Michael

sheershak agarwal

unread,
Jun 2, 2021, 3:46:55 PM6/2/21
to F´ Community Group
No, I haven't modified any code for the LinuxSerialDriver. Yes I do fprime-util purge to remove all the builds and then do the generate and build commands again.

I understand there is a queue overflow but can't seem to get why is that happening. The error occurs when I send the uart message twice, but I don't receive any message on the first try (which can mean the queue isn't processing it at all). Yes when I built the program this time my  LinuxSerialDriverComponentAc is also 1395 lines long but previously my files were longer than that. I don't what has changed and can't seem to get the old file back (line 1495 error). 

Would it be possible for you to provide a tutorial or project on just UART (where f-prime has just initialized uart and uart is working on your end)? or I can create it on my end and if the problems persists, you can try running it on your laptop and see where the problem is.

Canham, Timothy K (US 348C)

unread,
Jun 2, 2021, 3:56:59 PM6/2/21
to sheershak agarwal, F´ Community Group

I’ve made the mistake when I do the init() call that I put the wrong argument in for the queue depth. Check that.

 

Tim Canham

JPL Flight Software

sheershak agarwal

unread,
Jun 2, 2021, 4:25:28 PM6/2/21
to F´ Community Group
Thank you so much, I forgot to put the queue depth parameter in my init fuction. Once I added that Tx started working.
Reply all
Reply to author
Forward
0 new messages