How to continually transmit more than 1 byte.

In software serial, the write function only sends 1 byte at a time. Is there someway, some library, that i can send multiple bits/bytes, without stopping (and not using digitalWrite)? i want to be able to transmit at least 16 bits as opposed to just 8. Any help would be greatly appreciated!!

EDIT: I know i can send 2 bytes, or even 100 bytes. But the thing i'm trying to do is, implement my own LDPC(error correction) codes on the Arduino. Therefore, i'm taking a lot of channel measurements. One of them is figuring out how the error happens during the delay between the stop bit and the next startbit. Often times, this is were synchronization problems occur. So I'm trying to track this down. Hence why, I need to send more than 8 continuous bits. In software serial, it transmits 8 bits, then transmits the stop bit. then write() restarts on the next call. Instead of this, i just want to send more bits, like 64 bits for instance, and look at the BLER on the received data. (the reason why I'm staying away from hardware serial is because i'm doing this with wireless RF modules) Do you guys have any further info regarding this? I'm very grateful! Thank you so much!

See the description of Serial.write().

Would softwareserial's write work the same way? I saw the actual method, and it only took "byte" as the parameter.

I'm pretty sure "write" will only work with byte sized variables but it's not hard to break an int into two bytes.

I think this is one way you could send a 16-bit value.

void SendInt(int output)
{
  byte highOutput = output >> 8;
  byte lowOutput = output;
  mySerial.write(highOutput);
  mySerial.write(lowOutput);
}

There may be better ways to do this. (Edit: I'd be surprised if there aren't better ways to do this sort of thing.)

Edit again: Apparently "highByte" and "lowByte" are keywords in the Arduino IDE.

Here's one better way:

void SendInt(int output)
{
  mySerial.write(highByte(output));
  mySerial.write(lowByte(output));
}

Isn't there a version of the write() function that sends multiple bytes from a buffer ?

...R

Robin2: Isn't there a version of the write() function that sends multiple bytes from a buffer ?

...R

Yes. Documented on the reference page.

Robin2: Isn't there a version of the write() function that sends multiple bytes from a buffer ?

...R

Not in SoftwareSerial, at least not for version 1.0.5 or 1.6.6.

Why the array overload for write() was not implemented is a mystery. Doing so is a maximum of 7 lines of code, 4 of which are curly braces.

PaulS: Not in SoftwareSerial, at least not for version 1.0.5 or 1.6.6.

Why the array overload for write() was not implemented is a mystery. Doing so is a maximum of 7 lines of code, 4 of which are curly braces.

Presumably a bit of cut and paste from HardwareSerial would be worth while.

Of course it may have been left out because SoftwareSerial is so slow and it would just block for longer.

...R

Are you sure that version of write doesn't get inherited from Print?

From Print.cpp

/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
  size_t n = 0;
  while (size--) {
    n += write(*buffer++);
  }
  return n;
}

And from Print.h

virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
   return write((const uint8_t *)buffer, size);
}

Wow, thanks for all the replies. I know i can send 2 bytes, or even 100 bytes. But the thing i'm trying to do is, implement my own LDPC(error correction) codes on the Arduino. Therefore, i'm taking a lot of channel measurements. One of them is figuring out how the error happens during the delay between the stop bit and the next startbit. Often times, this is were synchronization problems occur. So I'm trying to track this down. Hence why, I need to send more than 8 continuous bits. In software serial, it transmits 8 bits, then transmits the stop bit. then write() restarts on the next call. Instead of this, i just want to send more bits, like 64 bits for instance, and look at the BLER on the received data. (the reason why I'm staying away from hardware serial is because i'm doing this with wireless RF modules) Do you guys have any further info regarding this? I'm very grateful! Thank you so much!

Jaraiya: Hence why, I need to send more than 8 continuous bits. In software serial, it transmits 8 bits, then transmits the stop bit. then write() restarts on the next call. Instead of this, i just want to send more bits, like 64 bits for instance,

You may have thought that your Original Post meant what you have said here, but I don't think anyone else did - certainly not me.

If you want to send 64 bits without a stop bit you will have to write your own version of SoftwareSerial. You may like to use my Yet Another Software Serial as a starting point.

I suspect, however, that it will be hard to maintain timing over 64 bits - but please feel free to try.

...R

I’ll edit the original post as well, then. thank you.

Jaraiya:
I’ll edit the original post as well, then. thank you.

Please don’t do that. It just screws up the sense of the Thread as all the replies so far will have referred to the original text.

Post your clarifications in a new Reply.

…R

Are you sure that version of write doesn't get inherited from Print?

Guess I didn't read far enough, or well enough...