Pages: [1]   Go Down
Author Topic: software serial serial.write  (Read 1855 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i want to send literal numbers out a software serial port, in the same way as serial.write allows me to do with the hardware serial port. But the software serial library does not seem to support a serial.write function.
the software serial serial.print function only sends ascii representations of numbers.

In particular I need to transmit numbers at the very bottom range of the ASCII table (e.g. 0, 1, 2...) that represent non-printable characters.

Is there any workaround for this? A lookup table for example, or a function to preprcess numbers into their corresponding ascii bytes?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 617
Posts: 49463
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you process the string on the receiving end, to convert it back to an integer?

Whether this was an oversight or a deliberate omission, I don't know. But, it does appear to be a limitation of both SoftwareSerial and NewSoftSerial.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunately I can't do anything on the receive end, short of convincing the device manufacturer to revise his code.
but since the software serial can send single bytes, there must be some way to get it to send the bytes I want. So far, the compiler refuses to accept arguments like "\0" or "NUL"  - possible names of these low-valued ascii characters.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 617
Posts: 49463
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess, then, that you are going to be limited to using a hardware serial port to communicate with this device.

The Mega has 4 such ports, if you need more than one. The SeeedStudio variant is not much more than an Arduino from SparkFun.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I have already applied the Megas in situations where I needed bidirectional serial communication with multiple serial peripherals  - it makes everything easier. I had just thought that in this situation, where data needs only to be sent and not received, that the software serial library would be applicable. it appears that it would not be too difficult to extend the library to include a serial.write function. Do you know who might be a good person to contact about this in a future revision.
Thanks
Logged

Rural Arizona
Offline Offline
Edison Member
*
Karma: 7
Posts: 1711
Incorrigible tinkerer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use the "serial.print(ascii_value, BYTE)" form of print() to send raw characters.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks! I will try this out!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes  -  using the BYTE argument does the trick.
Thanks so much!
Logged

Pages: [1]   Go Up
Jump to: