Connect to your serial port should look something like COM3 or USB 1121 6. OutputArea.ScrollPosition = OutputArea.LineNumAtCharPos(InStr(OutputArea. Use your A/B cable to connect your board to your computer 4. OutputArea.Text = ReplaceAll(OutputArea.Text, strNL, "") 'Handle the scroll position here, place scroll bar at bottom of window OutputArea.AppendText(Me.Read(buline,Encodings.ASCII)) Looking for the CR/LF at least gets me one whole line from the serial buffer into the OutputArea.ĭim buline as Integer = Instr(Me.LookAhead(Encodings.ASCII), Chr(13) + Chr(10)) I printed the length of the string from the ReadAll from the serial and found that I was typically reading only 2 to 7 characters at a time from the port. If there is a relay station in the connection it can be quite a few seconds before the next packet comes in, so this is not really speedy data! Those packets are only 128 characters with long time spans in between packets while the TNC sends an ACK over the 1200 baud half duplex radio link and gets a new packet. The buffer on the serial port was set to 4096 so that is a huge buffer for the short strings coming in from the radio packets. I guess I could replace the CR/LF with a Windows EOL, but this is working so I hate to mess with working code! Then I read that number of characters from the buffer plus 1 (for the LF character) and append that to the OutputArea. That gives me a pointer to the CR character. What I wound up doing was using Lookahead to find the first CR/LF sequence in the buffer using the Instr() function. I would think that failing flow control would miss characters and I have not seen that at all. I have RTS/CTS hardware flow control active. But again, if I was overflowing the buffer I would think that I would lose characters rather than have extra EOL sequences. I will look at the settings on the serial port and set the buffer to about 1024 characters and see if that helps. But they are short lines and the Buffer should hold the data. The TNC will send a series of lines with CR/LF EOL sequences. The Bar Code Reader would send a string with a Carriage Return and then be done. The original code was from the Bar Code Reader Serial Port Example that used Lookahead to watch for a Chr(13) (Carriage Return) and that exhibited the same behavior. I have used PUTTY for winders on these devices and it works fine along with Cool Term and Terra Term. Using breakpoints I have looked at the data from the TNC and there are no extra EOL sequences. I can turn off the Line Feed and that makes no difference. The EndOfLine characters from the TNC are always Carriage Return and Line Feed (hex 0D 0A). They are completely random, sometimes not occuring for several screens, and occurring in different places in the data stream. The baud rate change making it worse makes me think there is a timing problem with reading the data from the serial port. I have looked at the data from the TNC and there are no extra CR/LF in the data. Slowing down the baud rate makes the problem worse, so I am running at 9600 baud the fastest rate on the TNC. I can comment it out and I still get the extra blank lines in my OutputArea text. After entering the command codes on my coolterm window, I didnt receive the feedback. The scroll handling is from another forum post and seems to work fine. RN4871 command module set by Coolterm Ask Question Asked today Modified today Viewed 3 times 0 I need to use the RN4871 bluetooth module to control my MCU, so CoolTerm can be used to let it enter the Command Mode in UART. OutputArea.ScrollPosition = OutputArea.LineNumAtCharPos(InStr(OutputArea.Text, strNL)) There, a very useful program called CooltTerm receives the data and saves it into a. After a certain time (standard is 4h) the results are sent to a PC. OutputArea.Text = ReplaceAll(OutputArea.Text, strNL, “”) Basically, the the program counts signals from the gasmeter and does some arithmetics with it. 'Handle the scroll poistion here, place scroll bar at bottom of windowĭim strNL As String = Chr(133) //Use any ascii char here OutputArea.AppendText(linestr) // append cleaned string to the OutputArea Here is the code in the SerialController.DataAvailable event.ĭim linestr as String = Me.ReadAll(Encodings.ASCII) // Get buffer into a string Hw.usb_handle.I am reading serial data from a radio modem (Packet Radio TNC) and getting extra blank lines in the OutputArea. Hw.usb_handle.SetReceiveCallback(UsbCallback, UsbHandle::FS_INTERNAL) If ((dbgPtr - dbgBuf) >= (int)sizeof(dbgBuf)) or similar Both work fine to display from the Daisy USB CDC transmit. I’ve tried on Linux using cu “cu -l /dev/ttyACM0 -baud=115200”, and Mac using CoolTerm. As far as I can tell, it is never called. I simplified my code to just check for any activity on the UsbCallback. I was trying to get the USB CDC example to work so that I could use the serial console to let the Daisy know when I’m ready for it to run a test.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |