As far as I understood, serial communications (and even in both directions) are sometimes followed by a LF ( = chr(10) ) and not by a CR ( = chr(13) ) ; example : Elechouse VR3. Maybe it would be "elegant" to have this as an option (for each port individually, perhaps via a #Define Endchar ... ), so the characters could be sent and above all received as a string, instead of programming a loop to receive them a character at once ... Unfortunately this would not solve the issue caused by a chr(10) IN the string received (this can happen with VR3, thanks Murphy) !
Last edit: Bertrand BAROTH 2020-06-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For sending there is a little feature that may help.
In all the Serial libraries you can use the constants SERPRINTCR and SERPRINTLF. If you define the constants then the libraries will add a CR and/or LF to each serialPRINT command.
SERPRINTCR and SERPRINTLF is shown in the hardware serial commands but this applies to the software serial commands.
For receiving.
The user needs to develop the receive handler. At the moment the libraries receive and we enable the user to handle the incoming data.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A next implementation could be the use of structures (Type MyStruct) and the use of pointers.
In some of my projects in GcBasic I used an array instead of the structure so that you can save, for example, the device configuration with a simple for next.
This is an example of how I replaced the structure with an array.
The situation becomes more complicated when other types (eg word) or strings are used instead of the Byte variables.
The following code shows how I solved it in part:
@Bertrand. Yes this can be done. I need the exact parameters for USE.INI
Assume the following:
1. There is an option in the installer to install ATMEL ATprogram.exe
2. There will be a folder called ATMEL, under the GCB@SYN directory
3. The following will be installed in the ATMEL, under the GCB@SYN\ATMEL directory from this ZIP - https://github.com/Anobium/Tiny104_USART/blob/master/ATPrpogrammer/ATPrpogrammer.zip
4. There is a parameter in Tools Variables called atmelatprogramdir and is set to C:\GCB@SynRC18\ATMEL\atbackend
I recently added the ATMEL mEDBG using TPI using the following parameters.
[tool = atprogram]desc=ATMEL mEDBG using TPItype=programmeruseif=progconfig=command=%atmelATPROGRAMdir%\ATprogram.exeparams=-t mEDBG -i TPI -d AT%ChipModel% chiperase program -f "%FileName%"workingdir=%atmelATPROGRAMdir%\
I have attached USE.INI for you - you can get the ZIP from GitHub so you can test.
If you test on your setup, I just need the tool description for the STK2000 similar to what is shown above.
Sorry, I don't really understand ... I will wait for the next version of GCBasic, if STK200 is supported. Concerning the parameters ... I don't know them ! In fact I installed simply the software downloaded from Kanda's page (I only know that they use a FTDI chip)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As I do not know the STk200. What is kanda page? Does the page have the programming parameters? and, surely AVDUDE works with the STk200?
And, I just checked - ATPROGRAM does not support the STk200. Just these tools: avrdragon, avrispmk2, avrone, jtagice3, jtagicemkii, qt600, stk500, stk600, samice, edbg, medbg, nedbg, atmelice, pickit4, snap,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would do it this way:
A structure of this type:
Struct MyStruct
Name as string °16
Surname as tring * 16
GraduationYear as word
Other as byte
End Struct
Dim Myvar as MyStruct
First I would allocate an array of bytes of the total size of the entered variables.
So 17 + 17 of the strings,
2 bytes for the word variable
and another 2 bytes for the other two byte-type variables.
Therefore the memory to be allocated is 38 bytes.
Then I would create a pointer that points to the location of each of the variables, so 4 pointers.
Therefore it is necessary to create a descriptor managed by the compiler where the name of the pointer, the type of variable pointed to and its length is found.
Then the compiler based on the variable name.field name, for example MyVar.Name
When the program refers to one of these variables the compiler must read and write in those allocations in the way it reads and writes that type of variable.
I don't know if I explained myself well, English is not my language and I cannot express many words and concepts that exist in Italian in English.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As far as I understood, serial communications (and even in both directions) are sometimes followed by a LF ( = chr(10) ) and not by a CR ( = chr(13) ) ; example : Elechouse VR3. Maybe it would be "elegant" to have this as an option (for each port individually, perhaps via a #Define Endchar ... ), so the characters could be sent and above all received as a string, instead of programming a loop to receive them a character at once ... Unfortunately this would not solve the issue caused by a chr(10) IN the string received (this can happen with VR3, thanks Murphy) !
Last edit: Bertrand BAROTH 2020-06-21
For sending there is a little feature that may help.
In all the Serial libraries you can use the constants
SERPRINTCR
andSERPRINTLF
. If you define the constants then the libraries will add a CR and/or LF to each serialPRINT command.SERPRINTCR
andSERPRINTLF
is shown in the hardware serial commands but this applies to the software serial commands.For receiving.
The user needs to develop the receive handler. At the moment the libraries receive and we enable the user to handle the incoming data.
Thanks, it was only an idea and far from perfection ! As I wrote, in some situations, VR3 includes a LF into the data stream ...
Serial can be so flexible.. therefore it can be so frustrating. 😀
A next implementation could be the use of structures (Type MyStruct) and the use of pointers.
In some of my projects in GcBasic I used an array instead of the structure so that you can save, for example, the device configuration with a simple for next.
This is an example of how I replaced the structure with an array.
The situation becomes more complicated when other types (eg word) or strings are used instead of the Byte variables.
The following code shows how I solved it in part:
The name "DATI" is the name of the structure, the following word is the name of the corresponding variable.
Using pointers would also make the compiler much more complete.
Thank you. Both Structures and Pointers are on the list. One day....
Another friend of Pascal's records ...
:)
Last edit: Bertrand BAROTH 2020-07-07
And maybe You could include the support for the STK200 in USB version : in sequence Erase - Program flash - Verify flash ...
@Bertrand. Yes this can be done. I need the exact parameters for USE.INI
Assume the following:
1. There is an option in the installer to install ATMEL ATprogram.exe
2. There will be a folder called ATMEL, under the GCB@SYN directory
3. The following will be installed in the ATMEL, under the GCB@SYN\ATMEL directory from this ZIP - https://github.com/Anobium/Tiny104_USART/blob/master/ATPrpogrammer/ATPrpogrammer.zip
4. There is a parameter in
Tools Variables
calledatmelatprogramdir
and is set toC:\GCB@SynRC18\ATMEL\atbackend
I recently added the ATMEL mEDBG using TPI using the following parameters.
I have attached USE.INI for you - you can get the ZIP from GitHub so you can test.
If you test on your setup, I just need the tool description for the STK2000 similar to what is shown above.
Sorry, I don't really understand ... I will wait for the next version of GCBasic, if STK200 is supported. Concerning the parameters ... I don't know them ! In fact I installed simply the software downloaded from Kanda's page (I only know that they use a FTDI chip)
As I do not know the STk200. What is kanda page? Does the page have the programming parameters? and, surely AVDUDE works with the STk200?
And, I just checked - ATPROGRAM does not support the STk200. Just these tools: avrdragon, avrispmk2, avrone, jtagice3, jtagicemkii, qt600, stk500, stk600, samice, edbg, medbg, nedbg, atmelice, pickit4, snap,
I would do it this way:
A structure of this type:
Struct MyStruct
Name as string °16
Surname as tring * 16
GraduationYear as word
Other as byte
End Struct
Dim Myvar as MyStruct
First I would allocate an array of bytes of the total size of the entered variables.
So 17 + 17 of the strings,
2 bytes for the word variable
and another 2 bytes for the other two byte-type variables.
Therefore the memory to be allocated is 38 bytes.
Then I would create a pointer that points to the location of each of the variables, so 4 pointers.
Therefore it is necessary to create a descriptor managed by the compiler where the name of the pointer, the type of variable pointed to and its length is found.
Then the compiler based on the variable name.field name, for example MyVar.Name
When the program refers to one of these variables the compiler must read and write in those allocations in the way it reads and writes that type of variable.
I don't know if I explained myself well, English is not my language and I cannot express many words and concepts that exist in Italian in English.