cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC Creator & Designer Software

JoWi_3984961
New Contributor II

First I see it does not accept Python..the most popular language by most measures.

Visual Basic is not.

So I made the .py into a .EXE.

It runs, outputs, which is captured and displayed in your "output" window.

So far, so good.

But now the script needs an input, a COM port.

How can I get my reply through your output window into my EXE?

Why not just allow .py?

0 Likes
1 Solution
DheerajK_81
Moderator
Moderator

You can run python scripts directly from Creator. You just need to add the following in the post-build option:

"C:\Python27\python.exe" "C:\<project_dir>.cydsn\python_file.py"

If the python script needs a COM Port input, you will need to import the win32com.client as follows:

import win32com.client

pp = win32com.client.Dispatch("<Pass ProgID here>")  

#example usage: pp = win32com.client.Dispatch("PSoCProgrammerCOM.PSoCProgrammerCOM_Object")

In case you have many scripts to run, you can create a batch file with sequence of commands. Just ensure your python script terminates uses sys.exit() to ensure control is passed back. In the post build command, just specify the command as <filename>.bat.

Regards,

Dheeraj

View solution in original post

0 Likes
2 Replies
DheerajK_81
Moderator
Moderator

You can run python scripts directly from Creator. You just need to add the following in the post-build option:

"C:\Python27\python.exe" "C:\<project_dir>.cydsn\python_file.py"

If the python script needs a COM Port input, you will need to import the win32com.client as follows:

import win32com.client

pp = win32com.client.Dispatch("<Pass ProgID here>")  

#example usage: pp = win32com.client.Dispatch("PSoCProgrammerCOM.PSoCProgrammerCOM_Object")

In case you have many scripts to run, you can create a batch file with sequence of commands. Just ensure your python script terminates uses sys.exit() to ensure control is passed back. In the post build command, just specify the command as <filename>.bat.

Regards,

Dheeraj

View solution in original post

0 Likes
JoWi_3984961
New Contributor II

I got it working an easier way, but thanks!

0 Likes