cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 6 MCU

Anonymous
Not applicable

I'm trying to pass in information from a python script run on my computer to my psoc device (I'm on a Windows computer).

I'm currently trying to open a Serial com port in my python script, and write to that com port. (Below is what I added to my python script. For testing, currently just trying to send the letter "a".)

ser = serial.Serial("COM4", 115200, timeout=1)

while True:

     ser.write("a".encode())

Then within PSOC file, I have a UART that is able to read and write from a Com port too. Theoretically, I thought that if my python script wrote to a Com port, and my UART was connected to that same COM port, I'd be able to read information in. However, I have the issue that my python script will throw an error because the port is already open and I am not able to write to the COM port.

Is there some other way to do write from a python script and read that information into my PSOC? For my application, I have a script in Python that outputs coordinates. And I need the PSOC to take these coordinates and do stuff in response to the passed information.

0 Likes
1 Solution
MeenakshiR_71
Employee

Hello ddyuan_3344666​,

If my understanding is correct, you are trying to write to the same COM port from python which you have opened in another terminal software? And you want to push something to PSoC from Python and likely want to see the data in a terminal??

If yes, then you can try the following -

1. Use two UART blocks inside PSoC - one for Python interface and another for terminal/printf interface

2. Connect the printf interface to P5.0/1 and the Python interface to another port pin.

3. Connect the python interface pins to either a USB-Serial interface or another kit's UART pins (could be any kit that supports USB-UART interface - make sure the primary device in that kit does not load the UART lines). From the Python script, you can access the python interface COM port.

If the issue is the port access getting denied that it is because you might have the port already open in another software like a terminal. Closing that software would remove the error and you should be able to interact with PSoC.

Let me know if my understanding is correct and if the above pointers help your issue.

Regards,

Meenakshi Sundaram R

View solution in original post

0 Likes
2 Replies
MeenakshiR_71
Employee

Hello ddyuan_3344666​,

If my understanding is correct, you are trying to write to the same COM port from python which you have opened in another terminal software? And you want to push something to PSoC from Python and likely want to see the data in a terminal??

If yes, then you can try the following -

1. Use two UART blocks inside PSoC - one for Python interface and another for terminal/printf interface

2. Connect the printf interface to P5.0/1 and the Python interface to another port pin.

3. Connect the python interface pins to either a USB-Serial interface or another kit's UART pins (could be any kit that supports USB-UART interface - make sure the primary device in that kit does not load the UART lines). From the Python script, you can access the python interface COM port.

If the issue is the port access getting denied that it is because you might have the port already open in another software like a terminal. Closing that software would remove the error and you should be able to interact with PSoC.

Let me know if my understanding is correct and if the above pointers help your issue.

Regards,

Meenakshi Sundaram R

MeenakshiR_71
Employee

Hello ddyuan_3344666​,

If my understanding is correct, you are trying to write to the same COM port from python which you have opened in another terminal software? And you want to push something to PSoC from Python and likely want to see the data in a terminal??

If yes, then you can try the following -

1. Use two UART blocks inside PSoC - one for Python interface and another for terminal/printf interface

2. Connect the printf interface to P5.0/1 and the Python interface to another port pin.

3. Connect the python interface pins to either a USB-Serial interface or another kit's UART pins (could be any kit that supports USB-UART interface - make sure the primary device in that kit does not load the UART lines). From the Python script, you can access the python interface COM port.

If the issue is the port access getting denied that it is because you might have the port already open in another software like a terminal. Closing that software would remove the error and you should be able to interact with PSoC.

Let me know if my understanding is correct and if the above pointers help your issue.

Regards,

Meenakshi Sundaram R

View solution in original post

0 Likes
Top labels