This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hello everyone,
I am using the MSP together with an FTDI cable to try to transmit and receive data from the MSP to the PC with python. The "main" script should be the python script, where I want to send some data to the MSP, who has to do some stuff and then send data back.
I successfully received and transmitted data between the two interfaces. But until now I cannot do both - receive and then transmit. So the question is:
1. Do I need an exact timing to read out from the MSP, so that the data is ready when my python code reaches the read part? Meaning delay the python code until I think the MSP is finished with its calculations?
2. Or does the MSP feature a possibility to create an interrupt when the computer tries to read data over UART?
For better understanding just a raw idea what I want to do:
Python Code
import serial ser = serial.Serial('/dev/ttyUSB0') #do some stuff and generate data to send to MSP ser.write(data_raw) #and then do some stuff on the MSP #wait until MSP is finished? or directly read and MSP handles it like an interrupt and transmits data whenever it is ready? data_processed = ser.read()
I hope you understand what I mean.
Kind regards, LS
After sending the data to the USB port the FTDI will take some time to shift out that data. Exact timing depending on bit rate. Then the MSP430 does its thing and sends something back. Once again the amount of time depends on the bit rate.
So if you follow the ser.write with a ser.read, there will be no data waiting. You are going to have to wait for it.
Hello David,
thanks for your quick reply. So there is no MSP function to detect a ser.read() attempt and delay it on the MSP until the data is ready? I have to do it with the timing in python?!
Regards, LS
There is no way for the MSP430 to know when the host executes ser-read() unless you provide a signal. I know nothing about Python so I can't help you make it do what you want.
Hey LS,
This seems like more of a pySerial question on how to receive data from a COM Port. Your python code at some point will have to just wait to receive the data and have a timeout.
To very quickly break down the flow of how this communication will look like this: PC (Python program) --(COM PORT)--> FTDI chip --(UART)--> MSP430 RX - process command, respond- MSP430 TX --(UART)--> FTDI --(COM PORT)--> Python
If the MSP430 is going to respond, it will show up after an unknown amount of time that is dependant on the throughput/baud rates and how much processing was happening.
I would do some searching on stack overflow or some python forums.
Thanks,
JD
Ah! Thanks very much JD! I didn't think about, that I could also wait for a signal in python :) I will look through that!
Thank you very much for the help.
Regards, LS
**Attention** This is a public forum