Strange Serial MisComunication
Ok, so I have 3 devices.
- an AVR Butterfly microcontroller, set up with USART
- A Bifferboard, running Debian, using a custom made program for serial.
- A Desktop machine running Br@y's.
So I'm trying to make the Bifferboard send serial to the AVR, But the AVR never receives the signal, (we've checked the wires). But if i connect the AVR to the desktop box, and send with Br@y's it receives just fine.
If I connect the Bifferboard to the Desktop, Br@y's receives just fine.
Heres the code for the Bifferboard.
#include "string2num.h" //a custom header
#include <cstdlib>
#include <iostream>
#include <SerialStream.h>
using namespace LibSerial;
//using namespace std;
int main(int argc, char*argv[])
{
if (argc<2)
{
std::cout<<argv[0]<<" requires the device name eg \'dev/tty0\' as a parameter\nterminating.\n";
return 1;
}
SerialStream theSerialStream(argv[1]); //open the device
if(!theSerialStream.IsOpen()) //did the device succesfuilly open
{ //open faile
std::cerr<<"Open " << argv[1] << " failed\n Terminating.\n";
return 1; //exit failure
}
theSerialStream.SetVMin(0);//no min number of characters to send
theSerialStream.SetVTime(0);// don't wait betwenn characters开发者_如何学编程
theSerialStream.SetBaudRate( SerialStreamBuf::BAUD_19200);
theSerialStream.SetCharSize(SerialStreamBuf::CHAR_SIZE_8); //8
theSerialStream.SetParity(SerialStreamBuf::PARITY_NONE);// N
theSerialStream.SetNumOfStopBits(1);// 1
theSerialStream.SetFlowControl(SerialStreamBuf::FLOW_CONTROL_NONE);
std::cout<<"Ready for serial trasmission. Press Ctrl+C to quit\n";
//insert basic instructions here
while (1)
{
char input[BUFSIZ];
std::cin>>input;
char* values=getAllValues(input); //DECODE any formatting (this function is in the custom header)
std::cout<<"about to transmit: " << values << "\n";
theSerialStream << values;
free(values);
}
theSerialStream.Close();
return 0;
}
I've also tried using minicom from Bifferboard - it can talk to the desktop windows machine, but not the the AVR.
(We've checked the wires)
This still sounds like a cabling problem. If Br@y's can communicate with both, then it doesn't seem to be a configuration issue. You should throw a logic analyzer or oscilloscope on the receive pin (and probably probe other pins) of the AVR and see what's happening electrically when yo try to send data from the Bifferboard.
I'd bet that you see the data on some other pin. But I wouldn't bet a whole lot, because serial RS232 connectivity is such a touchy thing.
It's a long shot, but are all the serial ports running at the same voltage levels? I see the bifferboard has a 3.3V UART, whereas the AVR has a level convertor. The desktop port may be more flexible about voltage.
I'll throw out another "long shot" possibility. Depending on the transciever chip being used on a board it may not be able to produce its own negative supply voltage (typically via a charge pump) for RS232 levels. Some chips will "steal" their negative supply from the other side of the line, and that works great if you're talking to something like a PC. If both sides take that approach, however, it doesn't work out so great. Tranceivers like MAX232 (plus external caps and resistors) will generate their own negative supply, but chips like the DS275 don't.
精彩评论