0

I'm working on receive interrupt uart and I wanna store all of data as a string . I also catch data (one by one) byte until receiving ETX . When I catch ETX ,it means end of datas. unfortunately, my code doesn't work correctly and I catch incomplete datas in rcv_str_485 but rcv_array_485 is complete. that's strange and I beyond confused. I don't know what should I do for having datas as string . here is my variables :

Dim Rcv_str_485 As String * 1300
Dim Rcv_array_485(1300) As Byte At Rcv_str_485 Overlay

and here is my receive function:

Usart_rs485:
   Rcv_485 = Usartf0_data
   Select Case Num_data_485
      Case 1:

      Case 2:

         Rcv_array_485(rcv_counter_485) = Rcv_485
         Rcv_counter_485 = Rcv_counter_485+1
         If Rcv_485 = 03 Then 
            Num_data_485 = 3
         End If

      Case 3:
         Rcv_array_485(rcv_counter_485) = 0
         Waitus 10
         Rcv_complate_flag_485 = 1
         Num_data_485 = 2
         Rcv_counter_485 = 0
   End Select
Return
  • 1
    A very warm welcome to the site. Please note that it's not a free design house. People will help you take the next step if your question shows you've already done as much as you possibly could - which yours doesn't, I'm afraid. This is a few lines and a listing dump, wanting all the effort from others. Please edit your question and greatly improve it. Explain your own findings, thoughts and conclusions in considerable detail, don't just paste listings. The better the quality of your question, the better the quality of the answers it will attract. Again, welcome. – TonyM Nov 10 '21 at 09:26
  • thanks for your tips . I explained all details but the issue is very simple . I just want to have all what receives in uart as a string . by the way , I don't know basic language , just i know C language. – Milad Rasouli Nov 10 '21 at 09:54
  • *“by the way , I don't know basic language , just i know C language.”* Why aren’t you programming this in C then? – StarCat Nov 10 '21 at 16:48
  • Please [edit] your question and provide a minimal reproducible example. Are there any non-ASCII characters in your input stream, like UTF? How do you make sure that bytes received after ETX do not overwrite the former message? What exact difference do you see? – the busybee Nov 10 '21 at 19:19
  • Thanks . unfortunately , this project has wrote in "Basic"(Bascom) and I just have to add this unit to it . in UART I have a message from IEC62052-11 which I have to store on buffer and after receiving I will looking for required keywords in message and after that I make NULL buffer. the question is how can I have a message as a buffer and string in Basic (Bascom). – Milad Rasouli Nov 13 '21 at 05:12

0 Answers0