Go Down

Topic: Problem with SerialTransfer RS232 (Serial) connection Python and Arduino (Read 108 times) previous topic - next topic

drumy89

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



horace

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

drumy89

yeah but in the serial monitor is also crap.. there should it be right.

horace

the data is transferred as packets see 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

Go Up