SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By sdisselhorst
#94720
I am having a difficult time talking to two different serial devices. The heart of the problem is this: One device is using 7-e-1 and the other is using 8-n-1. Since it seems impossible to define those parameters, I can't seem to get them both to talk correctly. Any libraries out there which would allow me to "lock-in" the 7-e-1 on one port and 8-n-1 on the other?
By riden
#94721
If you saying that you want two devices to talk with each other and one uses 7-E-1 and the other 8-N-1, that won't directly work. You would have to have software UARTS on both devices so one sends 7-E-1/receives 8-N-1 and the other sends 8-N-1 and receives 7-E-1. Tricky, but it could be done. If you have a third device that needs to talk to these devices, you could use the hardware UART to talk with one device and a software UART to talk to other -- or 2 software UARTs.
By sdisselhorst
#94728
No, I am not saying that I am trying to get them to talk. I am capturing data coming in serially using 2400, 7-e-1. This is working. I then examine some of that data and print to a serial printer, if some criteria is met. The printer is 2400, 8-n-1. I can print to it in test sketches that don't include the 1st part (capturing) and it prints fine and accepts all of my commands. The problem comes in when I glue the two parts together since I can't define the parameters, it locks in on the 7-e-1 first and screws the printer stuff into garbage.

Also, I cannot change the printer to 7-e-1, which would solve the problem I'm sure.....
By riden
#94729
Okay, I think I understand now. Can't you continue to use the (hardware, I presume) serial port for the capture and then use a software UART to transmit the data to the printer? You mention "sketches", so are you talking Arduino? If so, have a look at the software UART library.
By stevech
#94730
sdisselhorst wrote:I am having a difficult time talking to two different serial devices. The heart of the problem is this: One device is using 7-e-1 and the other is using 8-n-1. Since it seems impossible to define those parameters, I can't seem to get them both to talk correctly. Any libraries out there which would allow me to "lock-in" the 7-e-1 on one port and 8-n-1 on the other?
can you alter the settings on either? What kinds of devices are these?
By sdisselhorst
#94739
This is an Arduino Mega and I am using Serial 1 for incoming and Serial 2 for outgoing. I am only using Serial 0 for programming. I cannot change the incoming parameters at all. I tried to change the printer's settings, but it didn't seem to work. I assumed it to be a problem with the printer, but I really don't know for sure. I do know it prints fine to the printer at 8-n-1 if I haven't first locked into the 7-e-1 from the incoming serial data first.

What I really was hoping to find is a library or something which would allow me to define the 7-e-1 on serial 1 and 8-n1 on serial 2 and have it really work.
By stevech
#94799
sdisselhorst wrote:What I really was hoping to find is a library or something which would allow me to define the 7-e-1 on serial 1 and 8-n1 on serial 2 and have it really work.
I've used Atmel mega's extensively but not Arduino. I'd think you could use those libraries to initialize the serial UART, then in your program, you add some C code to change the UART configuration. In standard C environments, this would be two lines of code. Post on this in the avrfreaks.net forum; you'll get a quick answer.