How-to
Serve a CSV Data Log From a Flexy to a ViewON Download Button
Short answer
Yes: generate the CSV in the Flexy user area under a fixed name, verify the Flexy serves it at /Data/Data.csv, then point a ViewON button's Load->URL action at that path. Keep the dated period filenames for the mail export, where an export block descriptor resolves the current name. No FTP server or cloud API sits between the operator and the file.
On this page
Yes, and the design that keeps the customer to a single click is to generate the CSV on the Flexy itself. Write it into the /usr/Data user area under one fixed browser-facing name, confirm the Flexy web service serves it at /Data/Data.csv, then give a ViewON button a Load->URL action aimed at that path. Keep the dated period filenames for the scheduled mail export, where an export block descriptor resolves the current name at send time. No FTP server, no cloud API and no client software sit between the operator and the file.
Decide where the file lives #
First settle who owns the downloadable copy. If the only CSV lives on the Comfort Panel's SD card, written by the panel's logging logic, the Flexy can reach it only through a transfer service that panel actually exposes: GETHTTP in the BASIC program when HTTP is available, GETFTP when FTP is. A panel that exposes neither gives the Flexy no network path to the file at all.
The resolving branch is local generation. A Flexy is documented to record 46 tags at one-second polling, so a production CSV seldom asks for more than the router already collects, and a locally written file feeds both the browser download and the mail export from one source. You also stop depending on the panel's transfer services staying enabled.
Two neighboring jobs have their own designs. Retrieving a file a panel keeps in its own storage is a separate troubleshooting problem; why an HMI's SFTP session cannot see the SD card data log files covers the usual failure when that is the chosen service. And if the real goal is to show the data on a screen rather than hand over a file, displaying PLC CSV data logs on an HMI screen is the design that fits that job.
Decision: generate on the Flexy. Pull the file with GETHTTP or GETFTP only when something external forces the panel to own it.
One file, two addresses #
The BASIC program and the browser reach the same storage through different addresses. The script opens the file with the file: prefix, so its name is file:/usr/Data/Data.csv. The web service has been shown to serve that same storage both at a direct link of the form /usr/Data/Data....csv and through the /Data/ mapping that generated pages use.
Test before wiring anything: in a browser session already authenticated to the Flexy, request the candidate path and use whichever form your firmware answers with CSV content. Prefer /Data/Data.csv for the button, because that is the mapping the generated links rely on.
One security note belongs here: that URL answers any authenticated Flexy session, so keep the customer account scoped to what it needs and treat the file as production data.
Never copy the file: URI into ViewON. The button carries the web path; the file: form is meaningful only inside the BASIC filesystem.
Write the CSV under one fixed browser name #
The dated scheme in the original script produces four archive names per month, selected by day:
| Day of month | Archive suffix | Days in the period |
|---|---|---|
| 1 to 8 | -01 | 8 |
| 9 to 15 | -09 | 7 |
| 16 to 23 | -16 | 8 |
| 24 to 31 | -24 | 8 |
The four ranges cover every day of a 31-day month exactly once: 8 + 7 + 8 + 8 = 31. February simply ends the last period early.
A static ViewON URL cannot work out which of the four names is current, so run two names in parallel: each record is appended to the dated archive, and the same record is appended to a fixed file that the button always requests.
- Derive the date parts from the clock string, exactly as the documented script does.
- Select the period suffix from the day and build the archive path in A$.
- Open that path with OPEN A$ FOR TEXT APPEND AS 2, write the CSV line, and close the file.
- Open file:/usr/Data/Data.csv the same way, write the same line, and close it. Finish each write before the file can be served or attached; a request that lands mid-buffer can receive an incomplete last record.
- At each period boundary, clear the fixed file so it mirrors only the current period. The dated archives keep the history.
T$ = Time$
D% = Val(T$(1 To 2))
M% = Val(T$(4 To 5))
Y% = Val(T$(7 To 10))
IF (D% > 0) AND (D% < 9) THEN
A$ = "file:/usr/Data/Data" + "-" + Y% + M% + "-01.csv"
ENDIF
IF (D% > 8) AND (D% < 16) THEN
A$ = "file:/usr/Data/Data" + "-" + Y% + M% + "-09.csv"
ENDIF
IF (D% > 15) AND (D% < 24) THEN
A$ = "file:/usr/Data/Data" + "-" + Y% + M% + "-16.csv"
ENDIF
IF (D% > 23) AND (D% < 32) THEN
A$ = "file:/usr/Data/Data" + "-" + Y% + M% + "-24.csv"
ENDIF
OPEN A$ FOR TEXT APPEND AS 2
In that block, T$ is the clock string, D%, M% and Y% are the integer day, month and year taken from it, and A$ is the archive path the open statement uses.
Worked example, 27 November 2025: the clock reads 27-11-2025, so D% = 27, M% = 11 and Y% = 2025. The tests 27 > 23 and 27 < 32 select the -24 block, and the concatenation of "Data", "-", 2025, 11 and "-24.csv" resolves to file:/usr/Data/Data-202511-24.csv. The mail descriptor for that day is $dtUF$uf/usr/Data/Data-202511-24.csv, while the ViewON button still requests /Data/Data.csv, unchanged. One formatting trap: M% is numeric, so March produces Data-20253-16.csv, not Data-202503-16.csv. Compare the directory entry's exact spelling against the string the descriptor resolves to before the first scheduled send.
At an example rate of one appended row per minute, the longest period holds 8 × 1440 = 11,520 rows at rotation, which is the number to keep in mind when judging attachment size.
Point the ViewON button at it #
- In a browser already authenticated to the Flexy, request /Data/Data.csv. CSV content in the window is success; a missing-resource or login page means the path or the session is wrong, and ViewON is not the place to debug it.
- In ViewON, create the button and assign its action: Load->URL, with the tested path as the value. For a resource sitting in the same web area as the pages themselves, the demonstrated relative form is ../file.csv; for the data directory, use the tested /Data/ path.
- If the customer needs a save dialog rather than an in-browser view, put a small HTML page in the usr directory whose only content is an anchor carrying a download attribute:
<a href="/Data/Data.csv" download>Download production CSV</a>
Point the button at that page instead. Browser policy and the response headers make the final save-or-display call, so the attribute is the suggestion you control.
Decision: an in-browser display still counts as a successful delivery. Add the HTML page only when the save dialog is a stated requirement.
Send the archive by mail without PUTFTP #
An export block descriptor attaches a Flexy user file directly: the documented form is the $dtUF$uf prefix followed by the resolved archive path, as in the worked example above. PUTFTP is not a prerequisite and has no role here; it exists to push a file to an FTP server or between Ewon units, and dropping it removes a step that can fail independently of the mail.
Scheduling is the planner's job, not the descriptor's. The documented pattern runs a descriptor export of a user file on a repeating cycle with the planner built into the Flexy; align the sends with the period changes on days 1, 9, 16 and 24 so each archive is complete when it leaves. For descriptor handling inside ViewON pages, configuring EBD files for ViewON browser downloads works through the same syntax in more depth.
Let the operator pick a period #
When the customer must reach earlier files, keep the date logic out of ViewON and generate an index instead. The demonstrated pattern builds the anchor list in a string, $HTMLPage in the example, with each link of the form '/Data/' + filename, and renders it from a plain HTML file placed in the usr directory whose content is the single server-side call:
<%#ExeSSI, PRINT #0, RESULT$%>
The ViewON button then links statically to that page, and the page lists whatever archives exist. Decision: use the index only when history selection is a real requirement; for one current file, the fixed name is simpler and cannot break.
Verify the chain end to end #
- /usr/Data holds both the fixed file and the current dated archive, each non-empty, with the last record complete.
- An authenticated request to /Data/Data.csv returns CSV content, not an error page.
- The button triggers a request to that same URL, visible in the browser's network view, never to a file: path.
- The archive suffix matches the active day range (01, 09, 16 or 24), and the month spelling in the descriptor matches the numeric concatenation in the directory.
- The mail attachment's name and content match the resolved descriptor path, and no FTP transfer occurs anywhere in the chain.
When all five hold, ship it: the operator's whole procedure is one button, and the archive reaches the mailbox on the planner's schedule.
Questions asked
Does the Flexy need an FTP server for the download button to work?
No. The button simply makes the browser request the file from the Flexy web service over HTTP, so the requirements are that the file exists under /usr/Data and that the browser holds an authenticated session to the Flexy. FTP only enters the picture if you separately decide to push the file to another server.
Can I email the CSV without running PUTFTP first?
Yes. A descriptor with the $dtUF$uf prefix attaches the user file straight from /usr/Data, so there is no intermediate transfer to perform. PUTFTP is for copying a file to an external FTP server or between two Ewon units; it is unrelated to the mail path, and leaving it out removes a step that can fail on its own.
Why does the button display the CSV instead of opening a save dialog?
Because a plain HTTP request for a text file may render it in the browser, and that still means the file was delivered. To suggest saving, point the button at a small HTML page whose anchor to /Data/Data.csv carries a download attribute. Browser policy and the response headers make the final call, so test on the customer's own browser.
The CSV has to stay on the Siemens panel. Can the button still work?
Yes. Pull the file into the Flexy with GETHTTP or GETFTP, whichever service the panel exposes, then serve the retrieved copy from /usr/Data under the fixed name. The ViewON side does not change at all; only the BASIC program gains a retrieval step ahead of the append.
Is there a programmatic way to collect these CSV files as well?
Yes. The Flexy REST API can also return the CSV files, which suits pulling them into another system or a script on a schedule. Keep that path for integration work; for the operator-facing page, the direct URL behind one button remains the simplest delivery.