Skip to content

Commit 1fffb4d

Browse files
authored
rs232: add ability to set serial baud rate from webui (#1016)
1 parent 7ce0cf6 commit 1fffb4d

File tree

7 files changed

+60
-6
lines changed

7 files changed

+60
-6
lines changed

data/webui/config/fujinet-rs232-rev0.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ components:
1212
hsio_settings: true
1313
timezone: true
1414
udp_stream: true
15+
serial_port: true
1516
program_recorder: true
1617
disk_swap: true
1718
boot_settings: true
1819
apetime: false
1920
pclink: false
2021
tweaks:
2122
# webui tweaks, if any
23+
platform: RS232

data/webui/config/fujinet-rs232-s3.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ components:
1212
hsio_settings: true
1313
timezone: true
1414
udp_stream: true
15+
serial_port: true
1516
program_recorder: true
1617
disk_swap: true
1718
boot_settings: true
1819
apetime: false
1920
pclink: false
2021
tweaks:
2122
# webui tweaks, if any
23+
platform: RS232

data/webui/template/www/index.tmpl.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,7 @@ <h3 style="text-align: center;">Need help? Go to the <a href="https://github.com
12391239
</div>
12401240
</div>
12411241
<div class="settings-content settings-45-55">
1242+
{% if not tweaks.platform == "RS232" %}
12421243
<div class="set">
12431244
<div class="settings-label">
12441245
<label for="serial_port">Serial Port</label>
@@ -1247,6 +1248,7 @@ <h3 style="text-align: center;">Need help? Go to the <a href="https://github.com
12471248
<input type="text" name="serial_port" id="serial_port" value="<%FN_SERIAL_PORT%>">
12481249
</div>
12491250
</div>
1251+
{% endif %}
12501252
{% if tweaks.platform == "ATARI" %}
12511253
<div class="set">
12521254
<div class="settings-label">
@@ -1297,6 +1299,26 @@ <h3 style="text-align: center;">Need help? Go to the <a href="https://github.com
12971299
<script>
12981300
var current_serial_baud = "<%FN_SERIAL_PORT_BAUD%>";
12991301
</script>
1302+
{% elif tweaks.platform == "RS232" %}
1303+
<div class="set">
1304+
<div class="settings-label">
1305+
<label>Baud Rate</label>
1306+
</div>
1307+
<div class="settings-value select">
1308+
<select name="serial_baud" id="select_serial_baud">
1309+
<option value="9600">9600</option>
1310+
<option value="19200">19200</option>
1311+
<option value="28800">28800</option>
1312+
<option value="38400">38400</option>
1313+
<option value="57600">57600</option>
1314+
<option value="115200">115200</option>
1315+
</select>
1316+
<span class="focus"></span>
1317+
</div>
1318+
</div>
1319+
<script>
1320+
var current_serial_baud = "<%FN_SERIAL_PORT_BAUD%>";
1321+
</script>
13001322
{% endif %}
13011323
<hr>
13021324
<div class="settings-text">
@@ -1305,11 +1327,17 @@ <h3 style="text-align: center;">Need help? Go to the <a href="https://github.com
13051327
Serial port for communication with an Atari computer.
13061328
{% elif tweaks.platform == "COCO" %}
13071329
Serial port for communication with a CoCo computer.
1330+
{% elif tweaks.platform == "RS232" %}
1331+
Serial port for communication for RS232.
13081332
{% else %}
13091333
Serial port for communication with a real computer.
13101334
{% endif %}
13111335
<br>
1336+
{% if tweaks.platform == "RS232" %}
1337+
Note: This must match the baud rate set for the FujiNet driver on the host machine
1338+
{% else %}
13121339
Note: To use it, configure above settings and disable communication with emulator.
1340+
{% endif %}
13131341
</div>
13141342
</div>
13151343
</div>

data/webui/template/www/js/settings.tmpl.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ setSerialCommand(current_serial_command);
185185
setSerialProceed(current_serial_proceed);
186186
{% elif tweaks.platform == "COCO" %}
187187
selectListValue("select_serial_baud", current_serial_baud);
188+
{% elif tweaks.platform == "RS232" %}
189+
selectListValue("select_serial_baud", current_serial_baud);
188190
{% endif %}
189191
{% endif %}
190192

lib/http/httpServiceConfigurator.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,17 @@ void fnHttpServiceConfigurator::config_serial(std::string port, std::string baud
572572
#endif
573573
}
574574
}
575+
#elif defined(BUILD_RS232)
576+
// RS232 Baud Rate
577+
void fnHttpServiceConfigurator::config_serial(std::string port, std::string baud, std::string command, std::string proceed)
578+
{
579+
if (!baud.empty())
580+
{
581+
//Debug_printf("Set RS232 baud: %s\n", atoi(baud.c_str()));
582+
Config.store_rs232_baud(atoi(baud.c_str()));
583+
Config.save();
584+
}
585+
}
575586
#endif // !ESP_PLATFORM
576587

577588
void fnHttpServiceConfigurator::config_boip(std::string enable_boip, std::string boip_host_port)
@@ -653,7 +664,7 @@ int fnHttpServiceConfigurator::process_config_post(const char *postdata, size_t
653664

654665
free(decoded_buf);
655666

656-
#ifndef ESP_PLATFORM
667+
#if !defined(ESP_PLATFORM) || defined(BUILD_RS232)
657668
bool update_serial = false;
658669
std::string str_serial_port;
659670
std::string str_serial_baud;
@@ -769,7 +780,7 @@ int fnHttpServiceConfigurator::process_config_post(const char *postdata, size_t
769780
{
770781
config_ng(i->second);
771782
}
772-
#ifndef ESP_PLATFORM
783+
#if !defined(ESP_PLATFORM) || defined(BUILD_RS232)
773784
else if (i->first.compare("serial_port") == 0)
774785
{
775786
str_serial_port = i->second;
@@ -813,7 +824,7 @@ int fnHttpServiceConfigurator::process_config_post(const char *postdata, size_t
813824
udpstream_activate();
814825
}
815826

816-
#ifndef ESP_PLATFORM
827+
#if !defined(ESP_PLATFORM) || defined(BUILD_RS232)
817828
if (update_serial)
818829
{
819830
config_serial(str_serial_port, str_serial_baud, str_serial_command, str_serial_proceed);

lib/http/httpServiceConfigurator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class fnHttpServiceConfigurator
3636
static void config_alt_filename(std::string alt_cfg);
3737
static void config_pclink_enabled(std::string pclink_enabled);
3838

39-
#ifndef ESP_PLATFORM
39+
#if !defined(ESP_PLATFORM) || defined(BUILD_RS232)
4040
static void config_serial(std::string port, std::string baud, std::string command, std::string proceed);
4141
#endif
4242
static void config_boip(std::string enable_boip, std::string boip_host_port);

lib/http/httpServiceParser.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ const string fnHttpServiceParser::substitute_tag(const string &tag)
6565
FN_PRINTER_ENABLED,
6666
FN_MODEM_ENABLED,
6767
FN_MODEM_SNIFFER_ENABLED,
68+
#if !defined(ESP_PLATFORM) || defined(BUILD_RS232)
69+
FN_SERIAL_PORT_BAUD,
70+
#endif
6871
#ifndef ESP_PLATFORM
6972
FN_SERIAL_PORT,
70-
FN_SERIAL_PORT_BAUD,
7173
FN_SERIAL_COMMAND,
7274
FN_SERIAL_PROCEED,
7375
FN_SIO_HSTEXT,
@@ -183,9 +185,11 @@ const string fnHttpServiceParser::substitute_tag(const string &tag)
183185
"FN_PRINTER_ENABLED",
184186
"FN_MODEM_ENABLED",
185187
"FN_MODEM_SNIFFER_ENABLED",
188+
#if !defined(ESP_PLATFORM) || defined(BUILD_RS232)
189+
"FN_SERIAL_PORT_BAUD",
190+
#endif
186191
#ifndef ESP_PLATFORM
187192
"FN_SERIAL_PORT",
188-
"FN_SERIAL_PORT_BAUD",
189193
"FN_SERIAL_COMMAND",
190194
"FN_SERIAL_PROCEED",
191195
"FN_SIO_HSTEXT",
@@ -390,6 +394,11 @@ const string fnHttpServiceParser::substitute_tag(const string &tag)
390394
resultstream << SIO.getHighSpeedBaud();
391395
break;
392396
#endif /* BUILD_ATARI */
397+
#if defined(BUILD_RS232)
398+
case FN_SERIAL_PORT_BAUD:
399+
resultstream << Config.get_rs232_baud();
400+
break;
401+
#endif
393402
#ifndef ESP_PLATFORM
394403
case FN_SERIAL_PORT:
395404
resultstream << Config.get_serial_port();

0 commit comments

Comments
 (0)