Skip to main content
added 70 characters in body
Source Link
Mikael Patel
  • 8k
  • 2
  • 16
  • 21

Why go over the bridge for water?

It is possible to access the data in the struct as a character pointer. No need to transfer to a buffer etc.

void loop() 
{ 
  ...
  ...
  const char* dp = (const char*) &dataRequest;
  for (int i = 0; i < sizeof(dataRequest); i++) Serial.print(*dp++);
  Serial.println();
  delay(1000);
  ...
  ...
 }

It might be hard to extrapolate how to receive this?

void loop() 
{ 
  if (Serial.available() > sizeof(dataRequest)) {
     char* dp = (char*) &dataRequest;
     for (int i = 0; i < sizeof(dataRequest); i++) *dp++ = Serial.read(); 
     Serial.read();
     ...
     ...
  }
}

The Serial.println() and extra Serial.read() could be replaced by a "frame marker" and/or a check-sum.

Cheers!

Why go over the bridge for water?

It is possible to access the data in the struct as a character pointer. No need to transfer to a buffer etc.

void loop() 
{  
  const char* dp = (const char*) &dataRequest;
  for (int i = 0; i < sizeof(dataRequest); i++) Serial.print(*dp++);
  Serial.println();
  delay(1000);
}

It might be hard to extrapolate how to receive this?

void loop() 
{ 
  if (Serial.available() > sizeof(dataRequest)) {
     char* dp = (char*) &dataRequest;
     for (int i = 0; i < sizeof(dataRequest); i++) *dp++ = Serial.read(); 
     Serial.read();
  }
}

The Serial.println() and extra Serial.read() could be replaced by a "frame marker" and/or a check-sum.

Cheers!

Why go over the bridge for water?

It is possible to access the data in the struct as a character pointer. No need to transfer to a buffer etc.

void loop() 
{ 
  ...
  ...
  const char* dp = (const char*) &dataRequest;
  for (int i = 0; i < sizeof(dataRequest); i++) Serial.print(*dp++);
  Serial.println();
  delay(1000);
  ...
  ...
 }

It might be hard to extrapolate how to receive this?

void loop() 
{ 
  if (Serial.available() > sizeof(dataRequest)) {
     char* dp = (char*) &dataRequest;
     for (int i = 0; i < sizeof(dataRequest); i++) *dp++ = Serial.read(); 
     Serial.read();
     ...
     ...
  }
}

The Serial.println() and extra Serial.read() could be replaced by a "frame marker" and/or a check-sum.

Cheers!

added 391 characters in body
Source Link
Mikael Patel
  • 8k
  • 2
  • 16
  • 21

Why go over the bridge for water?

It is possible to access the data in the struct as a character pointer. No need to transfer to a buffer etc.

void loop() 
{  
  const char* dp = (const char*) &dataRequest;
  for (int i = 0; i < sizeof(dataRequest); i++) Serial.print(*dp++);
  Serial.println();
  delay(1000);
}

It might be hard to extrapolate how to receive this?

void loop() 
{ 
  if (Serial.available() > sizeof(dataRequest)) {
     char* dp = (char*) &dataRequest;
     for (int i = 0; i < sizeof(dataRequest); i++) *dp++ = Serial.read(); 
     Serial.read();
  }
}

The Serial.println() and extra Serial.read() could be replaced by a "frame marker" and/or a check-sum.

Cheers!

Why go over the bridge for water?

It is possible to access the data in the struct as a character pointer. No need to transfer to a buffer etc.

void loop() 
{  
  const char* dp = (const char*) &dataRequest;
  for (int i = 0; i < sizeof(dataRequest); i++) Serial.print(*dp++);
  Serial.println();
  delay(1000);
}

Cheers!

Why go over the bridge for water?

It is possible to access the data in the struct as a character pointer. No need to transfer to a buffer etc.

void loop() 
{  
  const char* dp = (const char*) &dataRequest;
  for (int i = 0; i < sizeof(dataRequest); i++) Serial.print(*dp++);
  Serial.println();
  delay(1000);
}

It might be hard to extrapolate how to receive this?

void loop() 
{ 
  if (Serial.available() > sizeof(dataRequest)) {
     char* dp = (char*) &dataRequest;
     for (int i = 0; i < sizeof(dataRequest); i++) *dp++ = Serial.read(); 
     Serial.read();
  }
}

The Serial.println() and extra Serial.read() could be replaced by a "frame marker" and/or a check-sum.

Cheers!

Source Link
Mikael Patel
  • 8k
  • 2
  • 16
  • 21

Why go over the bridge for water?

It is possible to access the data in the struct as a character pointer. No need to transfer to a buffer etc.

void loop() 
{  
  const char* dp = (const char*) &dataRequest;
  for (int i = 0; i < sizeof(dataRequest); i++) Serial.print(*dp++);
  Serial.println();
  delay(1000);
}

Cheers!