I am trying to listen into a uart line between two devices. When a particular set of characters is sent, I want my Arduino to transmit a specific message. My issue is that it seams some characters that should be sent are getting lost... and also once I trigger one event, the remaining events do not send any characters, just line feed.... not sure why. I have attached my code, not sure if this was adequate explanation but please feel free to comment and suggest any solution. Thanks,
I'm sure this won't help but I have to ask - why do you use pins 11,12 for software serial?. This seems just dumb as they are used, if not strictly reserved, for SPI bus, but I saw somebody else do this recently, and I wondered if I am missing something.
beginit:
I want my Arduino to transmit a specific message
Is the Arduino intercepting the message (i.e. it receives it on one interface and transmits it on another - there is no direct path past it), or just listening to the message (i.e. the original message is also received at the ultimate destination)?
Robin2:
Why have you two separate instances of softwareSerial with the same name and different pins?
I wondered about that, but more about why use software serial at all.
I get the impression that this project is to eavesdrop on communication between two others, and signal when it hears something interesting. Maybe that has something to do with using software serial?
Is the Arduino intercepting the message (i.e. it receives it on one interface and transmits it on another - there is no direct path past it), or just listening to the message (i.e. the original message is also received at the ultimate destination)?
yes, the arduino is intercepting/ aka listening to the "transmit" line of one of the uart modules. when it hears something that it is listening for, it then connects "its" transmit line to the uart bus and sends its message to the same uart device that was being talked to. after it is done it "releases" the line by turning the pin into an input so as to allow normal non-arduino communication to occur.
Why have you two separate instances of softwareSerial with the same name and different pins?
again, this is so that I can listen on one pin without having the tx pin hold the line "mute". when I acutally want to send something after an event is triggered, that is when I change the pin assignments...
I wondered about that, but more about why use software serial at all.
using this on an attiny, no hardware uart lines....
thansk for all the help guys - and sorry for all the """""" uses
beginit:
when it hears something that it is listening for, it then connects "its" transmit line to the uart bus and sends its message to the same uart device that was being talked to.
Since the original transmitter will still be connected, and possible even still transmitting, the two output drivers will be fighting against each other. That's not a good idea, even if it works (which is far from certain). It would IMO be safer to intercept the incoming signal line and terminate it at a SoftwareSerial instance working as a receiver, and then echo each receiver character to the hardware Serial port which you arrange to have its Tx pin connected to the ultimate destination device.
I don't know whether the serial links are bidirectional, but if they are then you have the option of either connecting the return data through a similar path, or allowing it to pass directly i.e. not via the Arduino.
SoftwareSerial is rather limited especially when used to send (which is why I suggested using it to receive only) - the solution would be easier if you used an Arduino with two hardware serial ports.
Peter,
Thanks for the suggestion - that makes much more sense. The one caveat I would mention is I am 100% certain that once the original transmitter sends the trigger, it will be silent until the event is over. there is no change that two drivers will fight each other in that sense. My other issue is that I was hoping to do this with a attiny85.... so hardware uart lines are out. I understand the limitations of software serial, so if its not possible - that's the deal I will have to go back to the drawing board.... but if you can see any other way please let me know your thoughts...
It's a shame that the hardware UARTs are out, but I understand your reasoning. Do pay attention to the restrictions of SoftwareSerial, though - they have quite severe limitations.
Although the sender may not be transmitting, if it is holding the signal low then that will conflict with your SoftwareSerial Tx pin trying to drive it high. Each serial data line should at most one sending device connected, unless you add a circuit to stop them fighting against each other.