How to pass the value of a position to a variable, this position being received in ASCII?

Asked

Viewed 60 times

2

So I send you a piece of my script so you can help me. I need to return the variable rsp, that has always brought the value equal to 0, which was not to be done.

// Envia comando de Leitura de Posição 
serial.Write('R');
serial.Write('7');// controle: absoluto (1) pra cima(1)  e velocidade (3) 
serial.Write(' ');// angulo inicial 
System.Console.WriteLine("Comando enviado.");

// Espera a resposta da Luneta
rsp = serial.ReadChar(); 

System.Console.WriteLine("Resposta recebida.");

//Mostra resposta na Output Window
Console.WriteChar("Resposta: " + rsp);
  • 3

    Apparently, your problem isn’t in that code snippet. If rsp is at zero, serial.Readchar() is returning 0 and this is probably the fault of something internal to it, but we don’t know what is serial or where it is created/declared. There’s little context to understand.

  • So Pablo this serial is a communication port between a printed circuit board and pc. from RS485 to USB.

  • Then Marconcilio the code serves to move a bezel where initially we do not know where the angle is, so we have a value of the table ascii 'R' that receives this information. These values are displayed through a display. Initially this value of the rsp variable should be the value of 'R' which does not occur.

  • 1

    Thanks boys for the help, as Pablo had commented q could be something internal went looking for and really he was not transmitting the due value and I ended up having q exchange a pic q was using because he could receive but not transmit.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.