Arduino Forum

Using Arduino => Networking, Protocols, and Devices => Topic started by: drumy89 on Sep 22, 2020, 03:51 pm

Title: Problem with SerialTransfer RS232 (Serial) connection Python and Arduino
Post by: drumy89 on Sep 22, 2020, 03:51 pm
Hello Community,
I did a lot of research and Im trying since one day but I didnt find my mistake.

Im trying to send the values of fourth sensor via RS232 to Python/Capl(CANoe).

First of all I send every data seperatly via Serial.println, this isnt a big thing and its working fine but I will get timing issues if I not received all four sensor data at the same time.

For this I changed my communication from Serial.println to the SerialTransfer lib.

Im trying to send the sensor datas (the values are longs) via a struct but if I try to send something I will only get thrash.

So I start reducing my program to the basic (just sending two integer) but this doesnt work either!


Somebody of you has maybe an idea, where I did the mistake?

Code: [Select]

#include "SerialTransfer.h"

SerialTransfer myTransfer;

int data1 = 53;
int data2 = 54;

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

void loop(void)
{
  uint8_t sendSize = 0;
  //TorqueMeasurement(0);
  //RotaryAngleMeasurement(0);

  myTransfer.txObj(data1, sizeof(data1), sendSize);
  sendSize += sizeof(data1);

  myTransfer.txObj(data2, sizeof(data2), sendSize);
  sendSize += sizeof(data2);

  myTransfer.sendData(sendSize);
  delay(1000);
}



Best regrads,
Drumy


Title: Re: Problem with SerialTransfer RS232 (Serial) connection Python and Arduino
Post by: horace on Sep 22, 2020, 04:31 pm
you appear to be transmitting int type which on the Arduino are 16 bit signed integers
check what the receiver expects, e.g. I don't know about Python but C++ on a PC using gcc int is usually a 32bit signed integer
Title: Re: Problem with SerialTransfer RS232 (Serial) connection Python and Arduino
Post by: drumy89 on Sep 22, 2020, 06:26 pm
yeah but in the serial monitor is also crap.. there should it be right.
Title: Re: Problem with SerialTransfer RS232 (Serial) connection Python and Arduino
Post by: horace on Sep 22, 2020, 06:32 pm
the data is transferred as packets see SerialTransfer (https://github.com/PowerBroker2/SerialTransfer) therefore if you look at it as though it is normal ASCII if will appear as corrupt characters
the receiver needs to unpack it - see pySerialTransfer (https://github.com/PowerBroker2/pySerialTransfer)