Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No output from Execute script #3

Open
m0ivq opened this issue Nov 7, 2020 · 8 comments
Open

No output from Execute script #3

m0ivq opened this issue Nov 7, 2020 · 8 comments

Comments

@m0ivq
Copy link

m0ivq commented Nov 7, 2020

When using the execute script option, the target device pin states change but nothing is displayed in the console output window that pops up. Example script:

print ----------------------------
print Pin PE0 direction : 1
jtag_set_pin_dir   1 PE0 1
print Pin PE0 state : 0
jtag_set_pin_state 1 PE0 0
print Input pin PE0 state : 0

print ----------------------------
print Pin PE1 direction : 1
jtag_set_pin_dir   1 PE1 1
print Pin PE1 state : 1
jtag_set_pin_state 1 PE1 1
print Input pin PE1 state : 1

jtag_push_pop

pause 5000
@jfdelnero
Copy link
Member

I don't reproduce this issue. Which Windows version & language are you using ?

@m0ivq
Copy link
Author

m0ivq commented Nov 8, 2020

@jfdelnero this is on Windows 10 using VC++

I only have Visual Studio 2017 and had to retarget the project for the newer SDK version so this may be the cause. The VC6 code also suffered the same problem but it too had to retarget and would only run in release mode (not debug) due to other errors caused by the retarget.

I'll freshly clone the project and try to source the older SDK and see if that helps and close the issue accordingly.

@mrburns42
Copy link

I am also not able to get Execute script to work. However, on my machine, when I attempt to execute a sample script, then the application crashes. If I attempt to run it from Visual Studio, then it throws an exception but does not tell me where in the code it crashes.
Fair warning, I am a HW guy by trade. I am pretty good at embedded programming, but a total noobie at Windows stuff. I am using Microsoft Visual Studio Community 2019 Version 16.9.4. The code built in debug mode with no changes to anything. It updated the Project to the newer format, but that was all.
The operating system is Windows 10 ProVersion 20H2 OS Build 19042.928
I don't know what normal operation is since I have no experience with the GUI. However, then I execute the script, it seems like it wanted to open another window or panel before it crashes.

The exception when running from within Visual Studio is
Exception thrown at 0x7792731C (ntdll.dll) in JTAGBoundaryScanner.exe:
0xC0000005: Access violation reading location 0x73203335.

My script is very simple and is below. I was just trying to figure out what each statement does.
Other than the script, everything else that I tried is working. It is talking to the JTAG probe, loading the BSD file and seems to update the screen as the FPGA pins change.
Again, I am brand new to Visual Studio Community 2019. This is the very first project I have built, so the chance that it is some sort of operator error is high.

print ----------------------------
print Pin IO_N13 direction : 1
jtag_set_pin_dir 0 IO_N13 1
print Pin IO_N13 state : 1
jtag_set_pin_state 0 IO_N13 1
print Input pin IO_N13 state : 1

jtag_push_pop

pause 5000

@mrburns42
Copy link

So, I believe I may have more info on the crash. Running it in the debugger again, it got the exception on line 187 of JTAGBoundaryScanner.c
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))

Unhandled exception at 0xFCE9B530 in JTAGBoundaryScanner.exe: 0xE0464645 (parameters: 0x80070006, 0x80070006).

However, I can seem to prevent the crash by changing the line endings of the script file from DOS line endings to UNIX line endings. After making that change to the small sample script file, then the program does not crash. I get a small console type black window that appears briefly and then goes away.

@mrburns42
Copy link

By adding some breakpoints, I found that the console windows when briefly created would contain no text output. Goggling the symptoms and the Visual Studio version, I found that I had to make the following additions.

  1. Declare a global file handle. I called it fConsoleIO.
  2. In void openconsole() I added the calls,
    freopen_s(&fConsoleIO, "CONOUT$", "w", stdout);
    freopen_s(&fConsoleIO, "CONIN$", "r", stdin);
  3. In void closeconsole() I added the calls,
    fclose(stdin);
    fclose(stdout);
    fclose(stderr);
    fclose(fConsoleIO);

Without the additions in step3, the created console window would not close after adding the stuff from step 2. In void openconsole(), I found that the handle_out and handle_in were not required on my system once I added the freopen_s calls. It seems to be able to access printf and getchar without the handles.

Unsure of the side effects of any of these changes. It works on one machine with a very limited test case. However, I was at least able to run a script, see the output and then close that console window.

@m0ivq
Copy link
Author

m0ivq commented May 4, 2021

@mrburns42 are you able to fork the repository so I can test your changes on my setup? It seems that different VS versions exhibit different symptoms!

@jfdelnero
Copy link
Member

@mrburns42 Thanks for the tests and the patch, i will test it and merge it.

I confirm that i can reproduce the console issues with recent VS. I think that the proper way to definitively solve this issue is just to remove this console and use a proper window for this.

@mrburns42
Copy link

An update on the line endings of the script. The DOS vs UNIX is a red herring. While switching between them made a difference in the crash, the reason has something to do with the console window not being configured properly in the more recent VS. Once I added those few lines to the code, then it accepted both DOS and UNIX line endings.

If a different window is opened rather than a console, I would suggest that some option be added to save the contents of that new window. That way the results of running the script could be easily documented.

Thank you for this great open source project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants