Can KFLOP read string/char sent from PC?
Moderators: TomKerekes, dynomotion
Can KFLOP read string/char sent from PC?
Hi, KMotion gives a lot of predefined script commands in the library. However, I need to self-define new commands (strings) from PC to KFLOP. Does KFLOP have any function to read the strings sent from USB? Thanks.
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Can KFLOP read string/char sent from PC?
Hi xuphoenix,
The normal method for the PC to send User commands to KFLOP is to use the existing script commands to write a command codes (or strings) to KFLOP's memory. Your KFLOP User program can then detect the command, perform the operation, then clear the command to inform the PC the command has been completed.
See the Script commands: SetPersistDec and GetPersitDec. From KFLOP the persist Variables can be accessed as persist.UserData[X]
Larger blocks of data can use the 8MByte Gather Buffer see GetGatherDec and SetGatherDec. From KFLOP the gather buffer can be accessed as gather_buffer[X]
HTH
The normal method for the PC to send User commands to KFLOP is to use the existing script commands to write a command codes (or strings) to KFLOP's memory. Your KFLOP User program can then detect the command, perform the operation, then clear the command to inform the PC the command has been completed.
See the Script commands: SetPersistDec and GetPersitDec. From KFLOP the persist Variables can be accessed as persist.UserData[X]
Larger blocks of data can use the 8MByte Gather Buffer see GetGatherDec and SetGatherDec. From KFLOP the gather buffer can be accessed as gather_buffer[X]
HTH
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Can KFLOP read string/char sent from PC?
Thank you for your prompt response, Tom.
That script command can solve my problem. Is there any C program function that can detect the data update/change in the Persist Array? So that the KFLOP knows that a new command comes and needs to be executed. Thanks.
Best regards,
Yang
That script command can solve my problem. Is there any C program function that can detect the data update/change in the Persist Array? So that the KFLOP knows that a new command comes and needs to be executed. Thanks.
Best regards,
Yang
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Can KFLOP read string/char sent from PC?
Hi Yang,
Here is an example:
Here is an example:
Code: Select all
#include "KMotionDef.h"
#define VAR 10
void main()
{
for (;;) // forever loop
{
while (persist.UserData[VAR] <= 0) ; // wait for a non-zero command
// do the command
persist.UserData[VAR] = 0; // inform the PC command was completed or -1 for fail
}
}
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Can KFLOP read string/char sent from PC?
Got it. Thank you so much!
Best,
Yang
Best,
Yang