Serial port buffering
Tom P
Posts: 97
HELPPP
I want to be able to use a propeller to receive·serial data from an RF receiver and then resend a buffered serial stream out another port.
Has someone already done this? Can·someone·assist with some·code?
thanks in advance
Tom
I want to be able to use a propeller to receive·serial data from an RF receiver and then resend a buffered serial stream out another port.
Has someone already done this? Can·someone·assist with some·code?
thanks in advance
Tom
Comments
OBJ uart : "FullDuplex"
PUB Start
uart.Start(31, 30, 2400)
'Wait for serial input
repeat
GetSerialCommand
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 obj ser : "FullDuplexSerial" pub main ser.start(<input pin>, <output pin>, <mode(usually 0)>, <baud rate>) repeat ser.tx(ser.rx)
That will retransmit the serial stream as fast as possible with the same baud rate as input and output. If you want different baud rates:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 obj ser1 : "FullDuplexSerial" ser2 : "FullDuplexSerial" pub main ser1.start(<input pin>, <irrelevant>, <mode(usually 0)>, <baud rate>) ser2.start(<irrelevant>, <output pin>, <mode(usually 0)>, <baud rate>) repeat ser2.tx(ser1.rx)
The object ser2 transmits the data, and the object ser1 receives the data. This should do what you want. Change <input pin>, <output pin>, perhaps <mode>, and <baud rate> to your required data. With the FullDuplexSerial object there is no odd baud rate calculations as on the BS2. FullDuplexSerial has 16 byte internal buffers to prevent losing received data or having to wait to send data. If the baud rates are different, you might have problems transmitting packets as fast as they are received and vice-versa. The buffer sizes are changeable, but it requires a little work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1011, so be surprised!
I'am a bit confused? concerning the two sample codes shown - and to which one should be actaully used?
- Iam pretty new to the propeller,so bare with me here!
Bascially I want a real-time or near real time serial re-sending sceme. As data comes in its immediately re-sent but with buffering if needed, typically 2400baud
The incoming serial data could be displyed for debugging if possible (DEBUG) and get immediately re-sent out another port as a serial stream at the same speed.
I have a Propeller Demo board, could that be used for this project?
thanks in advance
Tom
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 obj ser1 : "FullDuplexSerial" ser2 : "FullDuplexSerial" pub main | char ser1.start(<input pin>, <output pin>, <mode(usually 0)>, <baud rate>) ser2.start(31, 30, 0, 9600) repeat char := ser1.rx ser1.tx(char) ser2.tx(char)
This example will send whatever is received out to the programming pins(31, 30) at 9600 baud so you can view it on the computer, and send the same data out to another pin at the input baud rate.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1011, so be surprised!
as the comments under the code-sample says
sample 1: same baudrate
sample 2: different baudrates
There are still some questions to clear:
What is the MAIN-purpose of this project ?
serial datastream debugging ?
or something else ?
If it is something else tell it to us. Maybe there is a completed different solution to the MAIN-purpose !
Are BOTH devices sending AND receiving data ?
(this would be a reason to use sample-code 2)
Does one or both of the devices use hardware-handshaking or software-handshaking that makes it nescessary to buffer the datastream?
If so - how many bytes have to be buffered ?
What voltage-levels do you need ?
Standard-RS232-devices are using +-12V
The Demoboard has ONE USB-to-serial-converter "onboard"
If the second port is a standard serial device you will need a voltageshifter 0/3,3V to -12V/+12V
What do you mean by (DEBUG)?
Debug-command as on a basic stamp meaning send a string to a serial port ?
Should this be a THIRD serial port ?
Displaying the incoming characters on a TV?, on a VGA ?
If you want to display the incoming or outgoing serial datastream you could do this
by using a Y-cable. Y-cable means the interested PIN Rx or Tx has a SECOND cable soldered
to the Rx/ Tx-Pin and the other end of this cable is connected to a third D-SUB9-Plug that
could be connected to a serial port of a PC to view the serial data.
best regards
Stefan
I want to experiment using the PRopeller Demo board
I understand I will have to substitute the pin numbers and baud rate.
In the program where its want <input pin> for example -- do I just insert 0 or P0 for the input/output pin?
--Also for baud rate what do I enter for say 2400 baud?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1011, so be surprised!
I entered the code in the propeller program and fired the demo board up.
I substituted the input numbers 0 for input and 2 for output, entered 2400 to start and tried to compile the program.
I get an error message [noparse][[/noparse]expected an expression term] and the word MODE was highlighted.
I did not change <mode <(usually 0).
What is this MODE command?
Tom
Sorry for all the questions!!
I figured out that the just needed to enter (0) for the mode after the baud rate, in your program example.
The I compiled the program and it got a bit further, but I got an error [noparse][[/noparse]variable needs operator]
with (char) was highlighted.
what do I need to do at thia point?
I think I'am almost there now!
thanks
Tom
For the other error message, you'll need to give a little context (like the line where the message refers).
I tried to recompile the program again but found another problem.
Now I get [noparse][[/noparse]variable needs operator] and the (char) under the repeat command in the debug version of the program gets highlighted!!
Getting closer
but no cigar!
tom
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1011, so be surprised!
Ops- I finally got ithe program to compile- there was no space between the char and the colon!
I have my receiver connected to the serial input (0)of the Propeller and an LCD connected to the serial output (2).
I get a lot of gibberish when I connect a serial LCD for test to the serial output at pin 2.
When I experimented with the STAMP 2 - I used -- SERIN 7, 16780, [noparse][[/noparse]WAIT ("*"), cnt ]
How can use an equivalent with the input on the propeller?
Also - how does debug work with the propeller? I did not see a debug screen or characters on the PC screen.
thanks in advance
Tom
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
ser1 : "FullDuplexSerial"
ser2 : "FullDuplexSerial"
pub main | char
ser1.start (0,2,0, 2400)
ser2.start (31,30,0, 2400)
repeat
char := ser1.rx
ser1.tx(char)
ser2.tx(char)
Ok you seem to be a guy that is aksing question very quickly
(i myself prefer to ask a SLOW questions combined with serving DETAILED information ALL AROUND my question)
You seem to like the ping-pong game of just quick asking getting a SMALL answer
and then asking quickly again
OK let's play ping-pong - i got a quick question too:
what baudrate has your LCD ?
i guess this way it will take about 20 SMALL questions and again 20 answers until your problem is solved
but i start enjoying this game
so just "pong" back
I'am a somewhat more familiar with the STAMP 2 but new to the propeller.
The LCD is set for 2400 baud, and I am trying to use the LCD to monitor the output of the serial port 2 on the Propeller.
I'am sending data from a STAMP2 collecting data from a number of TSL-230 sensors. The STAMP 2 is sending the data via radio to a receiver which is now connected to the propeller but was oringally connected to a second STAMP 2. SInce the STAMP 2 could not buffer the incomming serial data and retransmitt it I needed to try a different solution. I want to use the output of the serial port 2 on the propeller to send a serial signal to an serial internet device.
good posting !
i think now i have an overview about your project. You said on the LCD you get "gibberish"
There are different possabilities from where the error comes. Now you have to chase for the error
by excluding.
The principle is: reduce the number of components in the system and check the rest if it is working
properly. For checking use components with wich you are 100% sure that the checking component
is working properly
example: use serial port of a PC with hyperterminal instead of original device
reducing variety of the data:
make a small program for the propeller that will send ONE particular string like "123" every two seconds
connect the display directly to the propeller running this testprogram
does the display show correct data ?
maybe you have to change the mode-parameter
the modes are described in FullDuplexSerial.Spin in the PUB Start
make a small program for the basicstamp that will send ONE particular string like "123" every two seconds
connect the propeller directly (without radio-transmission in between) to the BS2 that sends out the data.
connect PC instead of LCD
test is the radio transmission Ok ?
precheck: BS2 sending out "123" connect BS2 directly to a PC serial port running hyperterminal
if receiving is OK install radio-transmitting in between:
BS2--->radio-tx---->radio-rx--->PC is the receiving still OK ?
then connect the display instead of the PC
BS2--->radio-tx---->radio-rx--->display
etc.
best regards
Stefan