I'm working on a project where I have to use my arduino as ADQ. Part of my code is the following.
- Code: Select all
SerialPort comport = new SerialPort();
comport.DtrEnable = true;
comport.RtsEnable = true;
try
{
comport.PortName = "/dev/ttyUSB0";
comport.BaudRate = Convert.ToInt32(115200);
comport.Open();
}
catch (Exception c)
{
Console.WriteLine(c);
return;
}
while (true)
{
int i = 0;
sw_error = new StreamWriter("fallos.txt", true);
sw1 = new StreamWriter("salida_01.txt", false);
sw2 = new StreamWriter("salida_02.txt", false);
while (i < (500+fallos))
{
string data = comport.ReadLine();
Console.WriteLine(data);
if (comprobar_errores(data))
errores(sw_error, sw1, data);
else
sw1.WriteLine(data);
i++;
}
sw1.Close();
sw_error.Close();
}
- Code: Select all
comport.BaudRate = Convert.ToInt32(9600);
- Code: Select all
comport.BaudRate = Convert.ToInt32(38400);
- Code: Select all
comport.BaudRate = Convert.ToInt32(57600);
- Code: Select all
comport.BaudRate = Convert.ToInt32(115200);
I've been looking for it in some forums but still can't find anything. The same code works great on Windows, so I guess is not Arduino's problem nor program's problem.
Thanks for your time and sorry for my English.
Best regards,
Raúl Suárez