Using sdPoSerial lazarus / 61-Beginners ---------------------------------------------------------------------- BLL · 2015-10-12 14:31 Hi, I have a RasPi model 2 and am running fpc 3.1.1 and lazarus 1.5. I am trying to use sdpoSerial from lazarus to read in a string of comma separated values from ttyUSB0 (9600,N,8,1), which talks to a PIC micro, which collects values from sensors and assembles them into a string with a comma following all but the last item, which is followed by a CR. I send a # and it returns the string. This works fine with a terminal program such as putty. sdpo only provides an OnPacketReceive function, which is clearly called each time a char appears. I have tried adding these to a string, but there are missing characters and the resultant string is rubbish!! I am really foraging in the dark! How should I go about doing it please? I have googled extensively but all the examples I have seen add the chars to a Memo. I want to get the characters as a string and then use the commatext function to add them to a stringlist, so each value is a string in the list. Any help much appreciated! ---------------------------------------------------------------------- eny · 2015-10-12 17:08 Show what you have done so far; post your code. My glass ball is empty after all the guesswork here http://forum.lazar us.freepascal.org/index.php/topic,29962.msg190204.html#msg190204. Again: tell what your results are so far and show in the code where you get the wrong results. ---------------------------------------------------------------------- ykot · 2015-10-12 19:25 For troubleshooting, you may also try TSysfsUART from PXL, where you can just call ReadString with some timeout to read the whole string on Raspberry PI and/or any other Linux machine. It doesn't need "cthreads". Something like: Code: [Select]var   SysfsUART: TSysfsUART;   Text: StdString; begin   SysfsUART := TSysfsUART.Create('/dev/ttyUSB0');   SysfsUART.ReadString(Text, 0, 250); // read any number of characters from UART   WriteLn('Text from UART: ', Text); ... end; Some available methods are documented here. ---------------------------------------------------------------------- Jkey · 2015-10-12 20:10 Use Ord function to get decimal code of the received "chars": Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Sdpo1RxData(Sender: TObject);var  Rx, Line: string;     i: integer;begin  Rx := Sdpo1.ReadData;  Line := '';  for i := 0 to Length(Rx)-1 do Line := Line + ' ' + IntToStr(Ord(Rx[i+1]));  Memo1.Lines.Add(Line);end; ---------------------------------------------------------------------- Jurassic Pork · 2015-10-12 21:57 hello, have a look to the example ( serial gps simulator and frames receiver ) which comes with my tlazserial component  : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFMain.Serial1RxData(Sender: TObject);var  Str: string;begin  Str := Serial1.ReadData;  CurPos := Pos(char(10), Str);  if CurPos = 0 then  begin    FTempStr := FTempStr + Str;  end  else  begin    FTempStr := FTempStr + Copy(Str, 1, CurPos - 1);    Memo.Lines.BeginUpdate;    Memo.Lines.Add(FtempStr);    Memo.Lines.EndUpdate;    Memo.SelStart := Length(Memo.Lines.Text) - 1;    Memo.SelLength := 0;    // Your code here    //    AnalyseTrames(FtempStr);    FTempStr := Copy(Str, CurPos + 1, Length(Str) - CurPos);  end;  //Serial1.WriteData('OK' + char(13) + char(10));end;    FTempStr is a global variable. example to fill a stringlist with a comma delimited string   : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const ReceivedString = 'value1,value2,value3,value4' ;var  i: integer;  MyList : TStringList;begin MyList := TStringList.Create(); MyList.CommaText := ReceivedString; For i :=0 to MyList.Count -1 do writeln(mylist[i]);end;Result : Quotevalue1 value2 value3 value4 Friendly, J.P