File Location? Or other problem

Discussion about various user interfaces such as web interface, displays and apps
Post Reply
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

File Location? Or other problem

Post by ChazFisher »

Dima - Now that I've been able to communicate with the STM32, I'm trying to run your Web Frontend. When I run your Huebner.bat file, everything seems OK, but it eventually just stops and the web page never opens up. Here's what the PowerShell window shows me:

Image

I have confirmed that COM5 is the correct port - if I run PuTTYtel and select COM5, I can communicate just fine with the board. My first thought is I've installed the files in the wrong location, and the php server can't find them. Your thoughts?
Chaz Fisher
Slowly creeping up on that e-motorcycle.
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

OK, update. The problem seemed to be in the openBrowser function in the run.ps PowerShell script. Of the three choices in the function (FireFox, Edge, and IE) I had Edge and IE installed. So I tried downloading and installing FireFox. Voila, not only did Firefox open, but I now see index.php loading up.
So I'll keep picking at this, and report back. Not sure why either of the Microsoft browsers wouldn't open, as the environment variables seemed correct. But here we are.
Chaz Fisher
Slowly creeping up on that e-motorcycle.
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

Closer, not there yet. Firefox opens up, but the menu doesn't seem to be working properly. Sometimes I get the menu bar, and sometimes I don't. When I do get the bar, clicking on the different menu options has no effect. There seem to be some odd, extraneous characters in that menu bar. This is using Firefox ver 68.0.2, latest as of today. Here's a screenshot:

Image

I did wonder if the problem was with the Javascript files that are loading up, according to the PowerShell window. So I downloaded and installed the latest version of Java. No improvement. Then I saw this under the Java.com Help:
Firefox no longer provides NPAPI support (technology required for Java applets)
As of September, 2018, Firefox no longer offers a version which supports NPAPI, the technology required to run Java applets. The Java Plugin for web browsers relies on the cross-platform plugin architecture NPAPI, which had been supported by all major web browsers for over a decade. The 64 bit version of Firefox has never supported NPAPI, and Firefox version 52ESR is the last release to support the technology. It is below the security baseline, and no longer supported.

Java applications are offered through web browsers as either a Java Webstart application (which do not interact with the browser once they are launched) or as a Java Applet (which might interact with the browser). This change does not affect Web Start applications, it only impacts Java Applets.
They also say that MS Edge doesn't support Java at all. Ideas? Maybe rearrange the order of checking for different web browsers to launch IE (shudder) first?
Chaz Fisher
Slowly creeping up on that e-motorcycle.
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

Last update: edited the run.ps1 PowerShell script to use Internet Explorer. First time thru, I got the safety warning window, but once I clicked thru that the script went a little farther and hung. I got the main menu up in the web browser, but still got no response when clicking on the selections. Second time thru, no safety warning (Cookie was set) and the web browser hung completely. I can clear cookies to get that first-time behavior, but in either case I still don't get a usable response.

It appears the last line in the PowerShell window, when things get humg up, is typically js/menu.json. So I'm assuming there's a Javascript issue of some kind. And I don't know anything about Java. :( Time for a little more study, I guess.
Chaz Fisher
Slowly creeping up on that e-motorcycle.
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: File Location? Or other problem

Post by dima »

I can see you are using a slightly older version for Windows. The COM detection shows COM manufacturer now. New copy here https://github.com/dimecho/Huebner-Inve ... indows.zip Use RS232-TTL adapter and not direct serial.
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

Thanks, Dima, I'll give it a try tomorrow. I have a correct TTL cable now, and have confirmed I can communicate with the Olimex directly via puTTYtel.

I wonder sometimes if I'm the only person trying to use Windoze. :)
Chaz Fisher
Slowly creeping up on that e-motorcycle.
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

Hi Dima, using your new version, I had it hang up in the openBrowser function in run.ps1. I'll admit i'm learning PowerShell scripting (and javascript, and php) on the fly here, but as I read the function it will identify whether a process exists running Firefox, MS Edge, or MS IE, but it will not actually open a new tab in any of those if the process exists, and there is no command to open a new browser process of any of those types. I ended up forcing a new IE process, as follows:
Chaz's new code wrote: function openBrowser {

# Open Internet Explorer
$app = Get-Process iexplore -ErrorAction SilentlyContinue
if (!$app) {
$ie = New-Object -com InternetExplorer.Application;
$ie.visible = $true;
}
$ie.navigate("http://127.0.0.1:8080/index.php");
}

# Comment out old openBrowser function
# $firefox = Get-Process firefox -ErrorAction SilentlyContinue
# $edge = Get-Process MicrosoftEdge -ErrorAction SilentlyContinue
# $ie = Get-Process iexplore -ErrorAction SilentlyContinue
# if (-Not($firefox) -And -Not($edge) -And -Not($ie)) {
# Start-Process -FilePath "http://127.0.0.1:8080"
# }
#}
This opens a new IE browser session, and opens index.php. I get the first "HIgh Voltage Warning" screen, but once I accept that the php code seems to hang up. However, if I Ctrl-C the PowerShell window, the main screen comes up in my browser, and all the pull-down menu choices are available. Of course, having closed the PHP server by closing the PowerShell window where it was started, I can't actually do anything, but it is a start!

(25 years ago I wrote C++ code for a living, but since then I haven't coded anything more complex than a MS Excel macro. This project is my attempt to revive those long-dormant skills. But this old dog creaks and groans trying to do tricks anymore!)
Chaz Fisher
Slowly creeping up on that e-motorcycle.
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

Dima, I think my problem is based on trying to talk directly to the Olimex via the onboard serial port. Maybe you have some code commented out that I need? For example in index.js, you have commented out:

$.ajax(serialWDomain + ":" + serialWeb + "/serial.php?init=115200", {

and instead the code to be executed is:

$.ajax("serial.php?init=115200", {

I see 'SerialWDomain' and 'SerialWeb' in a couple of other files, with the code always commented out.

I tried enabling the commented-out code, and commenting out the other. Now, after accepting the high voltage warning, I get teh main menu page back up, and I try the various options. But when I try to open a puTTYtel session using the 'Console" menu option, I get this error in my Powershell window:

[Sat Sep 7 16:15:12 2019] PHP Notice: Undefined index: serial in C:\Users\Charles Fisher\Documents\AC Controller\JHuebner\Frontend\Web\open.php on line 84
[Sat Sep 7 16:15:12 2019] PHP Notice: Undefined index: speed in C:\Users\Charles Fisher\Documents\AC Controller\JHuebner\Frontend\Web\open.php on line 84


Sure enough, if I just brute-force the puTTYtel command line like this, it works:

$command = "..\\Windows\\puttytel.exe -serial COM5 -sercfg 115200,8,n,1,N";

It's as if a couple of variables associated with the serial port aren't being filled in. Am I on the right track?
Chaz Fisher
Slowly creeping up on that e-motorcycle.
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: File Location? Or other problem

Post by dima »

No no, you are too deep into it - something is not right. I am guessing the serial.php is where it gets stuck. Windows UART works in "blocking" mode (I can't figure out how to make php work in uart non-blocking mode). Windows is the most difficult OS to code COM communication.

Ignore "$.ajax(serialWDomain + ":" + serialWeb + "/serial.php?init=115200", {" PHP server (by itself) can only handle one request at-a-time, it was an attempt to make serial multi-requests (commented out for a reason - did not work)

Best way to troubleshoot is to get last stuck line from php-server console window.
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

Fair enough. It does seem to me as if the php files are not able to read the comm port configuration information from serial.json. I say that because if I hard-code the information that would ordinarily be read from there into the Console command code, I can open the puTTYtel window and talk to the controller. But hard-coding that kind of information is not a solution, I agree.

First console window - this is using all the code, including the run.ps1 PowerShell script, from the latest version you linked me to up above. The code gets hung up before getting to any of the php files, and no browser opens on my desktop at all:

Image

Second console window - this uses my brute-force method to open Internet Explorer. At this point IE is open, but waiting for something (the blue circle spins endlessly).

Image

The first pass of the code that executed at 08:55:02 brought me to the High Voltage Warning window. I waited about 30 seconds before clicking "I Agree," which brought us to the second pass at 08:55:32.

Keep in mind I have verified that the comm port is able to communicate with the Olimex. For example, if I open puTTYtel directly, configured for COM5, I can issue "reset" to the Olimex, and it returns "2D".
Chaz Fisher
Slowly creeping up on that e-motorcycle.
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: File Location? Or other problem

Post by dima »

If Putty returns "2D" it means you flashed the bootloader but not the firmware :roll: can you issue inverter commands and get response back? example "get version"

I recommend going ESP8266 route. I'l do more troubleshooting on my end.
esp8266-1.png
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

If I issue "all" I get back a full listing of parameters. "list" gives a listing of all the available parameters, and their acceptable values. So I'm pretty confident I have both bootloader and firmware flashed. Plus I have the flashing green LED on the Olimex, which would indicate the timer ISRs are running.

Does the ESP8266 firmware include any php pages? Or is is a simple conversion of the serial link to TCP/IP and WiFi? It may be best for me to simply stick with a puTTYtel session if I want to use the serial port directly.
Chaz Fisher
Slowly creeping up on that e-motorcycle.
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: File Location? Or other problem

Post by dima »

ChazFisher wrote: Sun Sep 08, 2019 4:36 pm Does the ESP8266 firmware include any php pages?
Yes it is a compressed version of php pages.

Watch out for (Chinesium) Prolific USB-TTL adapters. They show OK for drivers but don't work properly.
Screenshot_2.png
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: File Location? Or other problem

Post by doobedoobedo »

For Windows CH340 based is much safer than FTDI: https://www.zdnet.com/article/ftdi-admi ... nt-update/
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

My working theory right now is that the php SESSION variable array isn't being passed from one page to another properly. Dima - any thoughts on what needs to be set in php.ini?

One more piece of information - I brute-forced Firefox to start, instead of Internet Explorer. No difference in the behavior of the pages. The fact that I can hard-code the puTTYtel command line and not only make the Console open, but can communicate successfully with the Olimex, makes me discount any problem related to the USB-TTL cable hardware. Here's the Device Manager window:

Image
Chaz Fisher
Slowly creeping up on that e-motorcycle.
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: File Location? Or other problem

Post by dima »

ChazFisher wrote: Tue Sep 10, 2019 12:47 am My working theory right now is that the php SESSION variable array isn't being passed from one page to another properly.
I say that is a good theory. Try removing C:\Program Files\PHP and let the PowerShell re-install it. I tested on Windows 7 and 10 and never had this issue.

A quick google revealed https://stackoverflow.com/questions/164 ... -next-page

Code: Select all

This could be a permissions issue. Check where your sessions are being written to (session.save_path in your ini
file). Usually, it is in the /tmp folder. But if it set to another folder and your web server does not have
permissions to write into it, you can encounter this issue.
Edit: I might have found a bug, re-download, try-again. Thanks
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

I downloaded the new version in its entirety, and tried to run it tonight. Good news is that running the batch file opened up IE without any of my brute-force methods. :) Bad news is the behavior of the web pages is still the same. I got the High Voltage Warning, clicked "I Agree," and the web page hung trying to reload. I tried deleting C:\Program Files\PHP, and the PowerShell scripts installed a new PHP server, but the pages still behaved the same. Here's the PowerShell window - you can see by the time stamps when I clicked thru the warning page and it tried to load the next page.

Image

I have another commitment, and can't work on it any more tonight, but I think I'm going to do some reading about what I might need to set in php.ini, to make sure all the pages have access to the global variables, like SESSION.
Chaz Fisher
Slowly creeping up on that e-motorcycle.
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: File Location? Or other problem

Post by dima »

Wow I am curious now, I tried it on multiple computers with multiple adapters with HW ver 1 and 3 cannot reproduce the issue.

Help troubleshoot this, using Firefox (not IE) go to Menu-> Web Developer -> Web Console and then open http://127.0.0.1:8080
Post here the console messages.
fx-dev.png
fx-console.png

Also what happens if you go directly to http://127.0.0.1:8080/serial.php?init=115200
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

I'll try those tonight. In the meantime, could you look at php.ini, and post up what's under [SESSION], please?
Chaz Fisher
Slowly creeping up on that e-motorcycle.
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: File Location? Or other problem

Post by dima »

100% default. php.ini-development file is copied to be php.ini

Code: Select all

[Session]
; Handler used to store/retrieve data.
; http://php.net/session.save-handler
session.save_handler = files

; Argument passed to save_handler.  In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
;
; The path can be defined as:
;
;     session.save_path = "N;/path"
;
; where N is an integer.  Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories.  This is useful if
; your OS has problems with many files in one directory, and is
; a more efficient layout for servers that handle many sessions.
;
; NOTE 1: PHP will not create this directory structure automatically.
;         You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
;         use subdirectories for session storage
;
; The file storage module creates files using mode 600 by default.
; You can change that by using
;
;     session.save_path = "N;MODE;/path"
;
; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process's umask.
; http://php.net/session.save-path
;session.save_path = "/tmp"

; Whether to use strict session mode.
; Strict session mode does not accept uninitialized session ID and regenerate
; session ID if browser sends uninitialized session ID. Strict mode protects
; applications from session fixation via session adoption vulnerability. It is
; disabled by default for maximum compatibility, but enabling it is encouraged.
; https://wiki.php.net/rfc/strict_sessions
session.use_strict_mode = 0

; Whether to use cookies.
; http://php.net/session.use-cookies
session.use_cookies = 1

; http://php.net/session.cookie-secure
;session.cookie_secure =

; This option forces PHP to fetch and use a cookie for storing and maintaining
; the session id. We encourage this operation as it's very helpful in combating
; session hijacking when not specifying and managing your own session id. It is
; not the be-all and end-all of session hijacking defense, but it's a good start.
; http://php.net/session.use-only-cookies
session.use_only_cookies = 1

; Name of the session (used as cookie name).
; http://php.net/session.name
session.name = PHPSESSID

; Initialize session on request startup.
; http://php.net/session.auto-start
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
; http://php.net/session.cookie-lifetime
session.cookie_lifetime = 0

; The path for which the cookie is valid.
; http://php.net/session.cookie-path
session.cookie_path = /

; The domain for which the cookie is valid.
; http://php.net/session.cookie-domain
session.cookie_domain =

; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript.
; http://php.net/session.cookie-httponly
session.cookie_httponly =

; Handler used to serialize data.  php is the standard serializer of PHP.
; http://php.net/session.serialize-handler
session.serialize_handler = php

; Defines the probability that the 'garbage collection' process is started
; on every session initialization. The probability is calculated by using
; gc_probability/gc_divisor. Where session.gc_probability is the numerator
; and gc_divisor is the denominator in the equation. Setting this value to 1
; when the session.gc_divisor value is 100 will give you approximately a 1% chance
; the gc will run on any give request.
; Default Value: 1
; Development Value: 1
; Production Value: 1
; http://php.net/session.gc-probability
session.gc_probability = 1

; Defines the probability that the 'garbage collection' process is started on every
; session initialization. The probability is calculated by using the following equation:
; gc_probability/gc_divisor. Where session.gc_probability is the numerator and
; session.gc_divisor is the denominator in the equation. Setting this value to 1
; when the session.gc_divisor value is 100 will give you approximately a 1% chance
; the gc will run on any give request. Increasing this value to 1000 will give you
; a 0.1% chance the gc will run on any give request. For high volume production servers,
; this is a more efficient approach.
; Default Value: 100
; Development Value: 1000
; Production Value: 1000
; http://php.net/session.gc-divisor
session.gc_divisor = 1000

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; http://php.net/session.gc-maxlifetime
session.gc_maxlifetime = 1440

; NOTE: If you are using the subdirectory option for storing session files
;       (see session.save_path above), then garbage collection does *not*
;       happen automatically.  You will need to do your own garbage
;       collection through a shell script, cron entry, or some other method.
;       For example, the following script would is the equivalent of
;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
;          find /path/to/sessions -cmin +24 -type f | xargs rm

; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
; http://php.net/session.referer-check
session.referer_check =

; Set to {nocache,private,public,} to determine HTTP caching aspects
; or leave this empty to avoid sending anti-caching headers.
; http://php.net/session.cache-limiter
session.cache_limiter = nocache

; Document expires after n minutes.
; http://php.net/session.cache-expire
session.cache_expire = 180

; trans sid support is disabled by default.
; Use of trans sid may risk your users' security.
; Use this option with caution.
; - User may send URL contains active session ID
;   to other person via. email/irc/etc.
; - URL that contains active session ID may be stored
;   in publicly accessible computer.
; - User may access your site with the same session ID
;   always using URL stored in browser's history or bookmarks.
; http://php.net/session.use-trans-sid
session.use_trans_sid = 0

; Set session ID character length. This value could be between 22 to 256.
; Shorter length than default is supported only for compatibility reason.
; Users should use 32 or more chars.
; http://php.net/session.sid-length
; Default Value: 32
; Development Value: 26
; Production Value: 26
session.sid_length = 26

; The URL rewriter will look for URLs in a defined set of HTML tags.
; <form> is special; if you include them here, the rewriter will
; add a hidden <input> field with the info which is otherwise appended
; to URLs. <form> tag's action attribute URL will not be modified
; unless it is specified.
; Note that all valid entries require a "=", even if no value follows.
; Default Value: "a=href,area=href,frame=src,form="
; Development Value: "a=href,area=href,frame=src,form="
; Production Value: "a=href,area=href,frame=src,form="
; http://php.net/url-rewriter.tags
session.trans_sid_tags = "a=href,area=href,frame=src,form="

; URL rewriter does not rewrite absolute URLs by default.
; To enable rewrites for absolute pathes, target hosts must be specified
; at RUNTIME. i.e. use ini_set()
; <form> tags is special. PHP will check action attribute's URL regardless
; of session.trans_sid_tags setting.
; If no host is defined, HTTP_HOST will be used for allowed host.
; Example value: php.net,www.php.net,wiki.php.net
; Use "," for multiple hosts. No spaces are allowed.
; Default Value: ""
; Development Value: ""
; Production Value: ""
;session.trans_sid_hosts=""

; Define how many bits are stored in each character when converting
; the binary hash data to something readable.
; Possible values:
;   4  (4 bits: 0-9, a-f)
;   5  (5 bits: 0-9, a-v)
;   6  (6 bits: 0-9, a-z, A-Z, "-", ",")
; Default Value: 4
; Development Value: 5
; Production Value: 5
; http://php.net/session.hash-bits-per-character
session.sid_bits_per_character = 5

; Enable upload progress tracking in $_SESSION
; Default Value: On
; Development Value: On
; Production Value: On
; http://php.net/session.upload-progress.enabled
;session.upload_progress.enabled = On

; Cleanup the progress information as soon as all POST data has been read
; (i.e. upload completed).
; Default Value: On
; Development Value: On
; Production Value: On
; http://php.net/session.upload-progress.cleanup
;session.upload_progress.cleanup = On

; A prefix used for the upload progress key in $_SESSION
; Default Value: "upload_progress_"
; Development Value: "upload_progress_"
; Production Value: "upload_progress_"
; http://php.net/session.upload-progress.prefix
;session.upload_progress.prefix = "upload_progress_"

; The index name (concatenated with the prefix) in $_SESSION
; containing the upload progress information
; Default Value: "PHP_SESSION_UPLOAD_PROGRESS"
; Development Value: "PHP_SESSION_UPLOAD_PROGRESS"
; Production Value: "PHP_SESSION_UPLOAD_PROGRESS"
; http://php.net/session.upload-progress.name
;session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS"

; How frequently the upload progress should be updated.
; Given either in percentages (per-file), or in bytes
; Default Value: "1%"
; Development Value: "1%"
; Production Value: "1%"
; http://php.net/session.upload-progress.freq
;session.upload_progress.freq =  "1%"

; The minimum delay between updates, in seconds
; Default Value: 1
; Development Value: 1
; Production Value: 1
; http://php.net/session.upload-progress.min-freq
;session.upload_progress.min_freq = "1"

; Only write session data when session data is changed. Enabled by default.
; http://php.net/session.lazy-write
;session.lazy_write = On
ChazFisher
Posts: 53
Joined: Wed Jul 03, 2019 1:32 am
Location: Central Virginia, USA

Re: File Location? Or other problem

Post by ChazFisher »

All right, here's what I did: I edited your run.ps1 script, to comment out the 'openBrowser' function call. That allowed me to start up the php server using your .bat file, but not have it start any browser up automatically. Once the PowerShell window showed that php had started, I opened Firefox and followed your instructions. Here's the result:

Image[/url]

In case it's too small to read, the message in the Console Window is:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/ jquery.js:2:80629
Chaz Fisher
Slowly creeping up on that e-motorcycle.
Post Reply