mk-soft,
many thanks for your patience.
Your code works good as it is.
If I replace #CRLF$ by CRLF$ it does not work.
\DataBit = 8
\StopBit = 1
\Handshake = #PB_SerialPort_NoHandshake
\BufferSize = 2048
\EndOfText = #CRLF$ <--------with only CRLF$ it do not work !
\StatusCB = @StatusCB()
\ReceiveCB = @ReceiveCB()
\ThreadID = CreateThread(@thComport(), ComData)
I think only 2 procedures are important for me
Procedure ReceiveCB(Text.s)
PostEvent(#My_Event_NewData,#window_main, 0, 0, AllocateString(Text))
EndProcedure
Procedure zend()
ComData\SendText = GetGadgetText(#str_input)
ComData\SendSignal = 1
EndProcedure
I am confused with the enumerations, sometimes you just use a number, I replace the number with a #name, this seems clearer to me.
I also always use an abbreviation for the type of gadget such as #but_, # window_, # str_ etc so that I know what kind of gadget it is.I don't have much experience.
Serial Port comunication witch arduino
Re: Serial Port comunication witch arduino
LogicalIf I replace #CRLF$ by CRLF$ it does not work.
CRLF$ is a variable of type String.
#CRLF$ is a ready string constant.
EnableExplicit at the beginning of the program should help.
With mini examples it can happen that one takes on the fast instead of constant names (enumeration) directly the numbers.I am confused with the enumerations, sometimes you just use a number, I replace the number with a #name, this seems clearer to me.
I also always use an abbreviation for the type of gadget such as #but_, # window_, # str_ etc so that I know what kind of gadget it is.I don't have much experience.
Normally I always use constant names, too.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Serial Port comunication witch arduino
MK-SOFT,
I am a bit confused about ' Global Comdata .uditComdata ' because it is declared later in the code and not after the structure udtComdata declaration .
The procedure thComport(*Comdata.udtComdata) refers to Comdata, and has not yet been declared.
If I understand correctly, it is not necessary to declare global variables at the top of the code.
Your code is of a very high level for me, it is not that easy for a beginner. But it works.
I am a bit confused about ' Global Comdata .uditComdata ' because it is declared later in the code and not after the structure udtComdata declaration .
The procedure thComport(*Comdata.udtComdata) refers to Comdata, and has not yet been declared.
If I understand correctly, it is not necessary to declare global variables at the top of the code.
Your code is of a very high level for me, it is not that easy for a beginner. But it works.
Re: Serial Port comunication witch arduino
Please read the basics of variables and structures in the PB help.
As well as what are pointers
Basics are important, and you should take the time to learn them.
---
P.S.
The procedure thComport(*Comdata.udtComdata) expects a pointer to the data with a structure of type udtComdata
So you can use the thread procedure more than once, for example to manage two comports.
But you have to create memory for the data. There are several ways. One of them is the one with Global VariablenName.TypeAsStructure.
Global ComData1.udtComdata
Global ComData2.udtComdata
As well as what are pointers
Basics are important, and you should take the time to learn them.
---
P.S.
The procedure thComport(*Comdata.udtComdata) expects a pointer to the data with a structure of type udtComdata
So you can use the thread procedure more than once, for example to manage two comports.
But you have to create memory for the data. There are several ways. One of them is the one with Global VariablenName.TypeAsStructure.
Global ComData1.udtComdata
Global ComData2.udtComdata
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive