Bug with Uart com !

Discussion in 'UDOO NEO' started by modjo, Jun 29, 2016.

  1. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    Hi i'm trying to send a structure since the M4 core to the A9 with Serial object. Under the structure that i send :

    Code:
    typedef struct stCom{
      uint16_t i_A0;
      uint16_t i_A1;
      uint16_t i_A2;
      uint16_t i_A3;
      uint16_t i_A4;
    }__attribute__ ((packed)); //for memory alignment
    stCom structCom={0};
    i use this structure for get the value of the adc 0 to 4 :
    Code:
    {
      structCom.i_A0=analogRead(A0);
      structCom.i_A1=analogRead(A1);
      structCom.i_A2=analogRead(A2);
      structCom.i_A3=analogRead(A3);
      structCom.i_A4=analogRead(A4);
    }
    then i send this structure to the A9 with :

    Code:
    Serial.write((char *)&structCom,sizeof(stCom));
    if i send this values :

    Code:
      structCom.i_A0=1124;
      structCom.i_A1=2148;
      structCom.i_A2=1526;
      structCom.i_A3=3125;
      structCom.i_A4=4095;
    i receive all the correct value in A9 side, but if they have a 0 in a var member, they don't send all the data, see under (i_A1 member) :

    Code:
      structCom.i_A0=1124;
      structCom.i_A1=2048;
      structCom.i_A2=1526;
      structCom.i_A3=3125;
      structCom.i_A4=4095;
    i receive on A9 side
    1124
    0
    0
    0
    2
    and the size of the packet is not 10 but 2 !!!

    I have check my code on a arduino leonardo and i works fine, udooTeam (@Andrea Rovai ), can you help please ?
     
  2. Uhl

    Uhl New Member

    Joined:
    Jun 30, 2016
    Messages:
    3
    Likes Received:
    5
    Hi,

    i just got started with my udoo neo. For another project I am also working with the solox.
    We also ran into problems with the communication of the M4/A9.
    We saw that the driver has some problems when sending special characters and then stopped working or filled up data with 0.
    We are running a FreeRtos on the M4 but I guess the problems will be pretty much the same, assuming that the Udoo is using the drivers provided by Freescale (can anyone confirm this?)
    We encoded our data in Hex before we are sending it to avoid special characters in the stream.
    On the weekend I'll try to setup my new Udoo and may be able to do some tests on this.

    Hope this helps!
     
    waltervl and modjo like this.
  3. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    Thanks for your answer ! For the moment i have resolve my problem like that --> I send all my data in a string terminated with a return carriage, but it take more resource to do that ! Otherwise i saw another bug, if i try to construct a String Object with a float like that :
    String stringOne = String(5.698, 3);

    I have a compiler error : it don't find the fonction char *dtostrf (double val, signed char width, unsigned char prec, char *sout)
    Use in WString.cpp. I have resolve this, just copy the dtostrf.h and c (~/.arduino15/packages/UDOO/hardware/solox/1.6.6-00004-gfff4787/cores/arduino/avr/) in (~/.arduino15/packages/UDOO/hardware/solox/1.6.6-00004-gfff4787/variants/udooneo/) but when i use it the M4 freeze !
     
  4. Uhl

    Uhl New Member

    Joined:
    Jun 30, 2016
    Messages:
    3
    Likes Received:
    5
    Maybe the string functions do not exist on the M4 arduino libraries. I think just copying the sources will not help much. The build is fine but during runtime the library is not found.
     
  5. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    Hi guys!
    @Uhl: we also use Freescale drivers. Which drivers are you talking about specifically? You can find everything on GitHub, everything is public :)
    @modjo: yes, there are problems with the string functions, in the guide there is a section about how to overcome these problems.
     
  6. Uhl

    Uhl New Member

    Joined:
    Jun 30, 2016
    Messages:
    3
    Likes Received:
    5
    Hi,

    I'm talking about the rpmsg driver on the A9 (Linux) side. I wasn't correct, the driver is made by TI I guess.
    As I said, I'm currently working with this driver because we are not really satisfied with the performance.
    I noticed the strange behavior with the strings (which can be fixed in the application).
    Another thing which I just currently found out is that there seems to be local echo turned on when using the tty driver. This leads to the situation that every received message on the A9 will be forwarded byte wise to the M4. This seems to slow down the performance quite a bit.
    I'll post some updates here if it is helping.
     
    Andrea Rovai, waltervl and modjo like this.
  7. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Last edited: Oct 5, 2016
  8. Francesco

    Francesco Active Member

    Joined:
    Jun 23, 2015
    Messages:
    220
    Likes Received:
    110
    /dev/ttyMCC has been greatly improved in the past weeks. Did you still get issues with UDOObuntu 2.1 ?
     
    Andrea Rovai likes this.
  9. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    I was not aware of a new version of Udoobuntu! So I made an announcement for this :)
     
    Andrea Rovai likes this.

Share This Page