dle Posted December 1, 2016 Share Posted December 1, 2016 Hi Guru, I'm using Renesas synergy USB device which showing virtual COM device on the computer. The code I wrote for the Renesas is: if (buffer == '\r') { break; } I be able to putty to send a string to the Renesas USB device and read back whatever I sent before the enter key is pressed. I try with DF such as device.myCOMdevice.write("myString" + Chr(13)) I don't receive any feedback from the device. I don't think Chr(13) would act like '\r' when it write to the Renesas Do you have any suggestion? Thanks. Link to comment Share on other sites More sharing options...
AzeoTech Posted December 1, 2016 Share Posted December 1, 2016 DAQFactory doesn't evaluate \r as carriage return in strings. It evaluates it as the two characters \ and r. You probably want: if (buffer == chr(13)) Link to comment Share on other sites More sharing options...
dle Posted December 1, 2016 Author Share Posted December 1, 2016 The below is C code in the renesas MCU, not DF script if (buffer == '\r') { break; } Link to comment Share on other sites More sharing options...
dle Posted December 1, 2016 Author Share Posted December 1, 2016 I think device.myCOMdevice.write("myString" + Chr(13)) does come with a line feed with it ? Link to comment Share on other sites More sharing options...
AzeoTech Posted December 1, 2016 Share Posted December 1, 2016 No, DAQFactory doesn't add line feeds except in the File. functions when writing to a file that you've opened as a text file. For serial comms, it only outputs what you specify, and everything is considered binary. So your statement will only send out a carriage return (ascii 13), not a line feed (ascii 10) Link to comment Share on other sites More sharing options...
dle Posted December 2, 2016 Author Share Posted December 2, 2016 Figure out the problem. Using Putty, every time I stroke a key, a byte is sent to Renesas MCU and therefore, I have to work around with DF by sending 1 byte at a time such as Device.myCOMdevice.Write(first Character) Device.myCOMdevice.Write(Second Character) ....... Device.myCOMdevice.Write(Chr(13)) I believe the command below also sending 1 byte at a time. It could be the timing issue? device.myCOMdevice.write("myString" + Chr(13)) I did not see this kind of problem when I was using 8051 MCU. Link to comment Share on other sites More sharing options...
AzeoTech Posted December 2, 2016 Share Posted December 2, 2016 Serial comms is always one byte at a time. However, that doesn't mean the remote device can handle it at full speed. It may only have a 1 byte incoming buffer and be busy with other things (like processing the previous character). Surprising since the baud rate of the serial port limits the speed DAQFactory can send bytes out and you would think the hardware manufacturer would reduce the maximum supported baud rate to ensure this doesn't happen. You have two choices I see: 1) lower the baud rate 2) create a routine that outputs one byte at a time. Its pretty easy: function writeSlow(string out) for (private i = 0, i < getlength(out), i++) device.myComDevice.write(mid(out,i,1)) endfor Then instead of doing device.myComDevice.write(), you would do: writeSlow("myString" + chr(13)) You could add a delay(1) in the the loop too if you want, but my guess is you don't need it. You might add the chr(13) into the function so you don't have to specify it every time... Link to comment Share on other sites More sharing options...
urdey Posted January 28, 2018 Share Posted January 28, 2018 Hi GURU .After creating a sequence and try to run the sequence I am getting C1000 Channel or function not found: Serial_Comms Line 2 - Uncaught error in sequence Serial_Comms Link to comment Share on other sites More sharing options...
AzeoTech Posted January 29, 2018 Share Posted January 29, 2018 I'd have to see the sequence. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.