I am trying to use a python console from my PC to read from and write to an embedded C application running on a microblaze host. The connection between the two is USB -> UART through a FTDI chip.
Brief Note on my skills/background: RF/Microwave Engineer, lots of hardware experience and lots of HDL experience, however little to no software experience, certainly none in C or python.
Problem/Questions:
Here is a snippet of code describing the uart_write function:
*
void uart_write_char(char data)
{
putchar(data);
}
* I would like to know if there is a difference between 'printing' data to console and 'transmitting' data to the other end, so I can receive it and dump it to a file.
Edit: I have also tried query_ascii_value() and query_binary_value() as documented in https://media.readthedocs.org/pdf/pyvisa/1.6/pyvisa.pdf The result is still the same, I receive a Timeout error in my python console.
UPDATE I have used NI-MAX to capture the Trace IO and the timeout appears to be on the read side. If I am connected to the device, I assume it will complete the write function, is this true? Here is the Ni-MAX log
viOpenDefaultRM (0x00001001) Process ID: 0x000082C8 Thread ID: 0x00006F90 Start Time: 15:21:12.0642 Call Duration 00:00:00.0139 Status: 0 (VI_SUCCESS)
viClose (0x00000000) Process ID: 0x000082C8 Thread ID: 0x00006F90 Start Time: 15:21:12.0781 Call Duration 00:00:00.0000 Status: 0x3FFF0082 (VI_WARN_NULL_OBJECT)
viParseRsrcEx (0x00001001, "ASRL6::INSTR", 4 (0x4), 6 (0x6), "INSTR", "ASRL6::INSTR", "COM6") Process ID: 0x000082C8 Thread ID: 0x00006F90 Start Time: 15:21:12.0781 Call Duration 00:00:00.0000 Status: 0 (VI_SUCCESS)
viOpen (0x00001001, "ASRL6::INSTR", 0 (0x0), 0 (0x0), 0x00000001) Process ID: 0x000082C8 Thread ID: 0x00006F90 Start Time: 15:21:12.0792 Call Duration 00:00:00.0657 Status: 0 (VI_SUCCESS)
viParseRsrcEx (0x00001001, "ASRL6::INSTR", 4 (0x4), 6 (0x6), "INSTR", NULL, NULL) Process ID: 0x000082C8 Thread ID: 0x00006F90 Start Time: 15:21:12.1450 Call Duration 00:00:00.0000 Status: 0 (VI_SUCCESS)
viWrite (ASRL6::INSTR (0x00000001), "tx_lo_freq?...", 14 (0xE), 14 (0xE)) Process ID: 0x000082C8 Thread ID: 0x00006F90 Start Time: 15:21:24.5897 Call Duration 00:00:00.0000 Status: 0 (VI_SUCCESS)
- viRead (ASRL6::INSTR (0x00000001), 0x000001DF461F5420, 20480 (0x5000), 0 (0x0)) Process ID: 0x000082C8 Thread ID: 0x00006F90 Start Time: 15:21:24.5897 Call Duration 00:00:02.0006 Status: 0xBFFF0015 (VI_ERROR_TMO)
I appreciate any advice on this issue and am happy to provide some more code snippets/info. Also keen for any feedback regarding post etiquette and potential for improving the post request
Cheers,
For completeness, I manage to work out a solution using NIMAX to trace all VISA transactions and a VISA test panel to achieve a working state, which I could then implement in my code
The issue: I was setting the baud rate and read/write termination characters in my instrument class definition and they were never getting implemented. It appears that I was trying to query with default settings of BAUD=9600 and incorrect read termination.
The Fix, I moved the lines of code which set the baud rate and read termination into my device class so that when I define the device as an Instrument, it sets these attributes before any transactions occur. Now I can read and write just fine.
Cheers,
User contributions licensed under CC BY-SA 3.0