Skip to content

Commit 8d89f83

Browse files
FozzTexxtschak909
authored andcommitted
Added status command to get the time when a drive was mounted.
1 parent a7b7642 commit 8d89f83

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

lib/device/rs232/disk.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extern rs232Fuji theFuji;
3333
rs232Disk::rs232Disk()
3434
{
3535
device_active = false;
36+
mount_time = 0;
3637
}
3738

3839
// Read disk data and send to computer
@@ -225,6 +226,7 @@ mediatype_t rs232Disk::mount(FILE *f, const char *filename, uint32_t disksize, m
225226
case MEDIATYPE_UNKNOWN:
226227
default:
227228
device_active = true;
229+
mount_time = time(NULL);
228230
_disk = new MediaTypeImg();
229231
return _disk->mount(f, disksize);
230232
}
@@ -249,6 +251,7 @@ void rs232Disk::unmount()
249251
{
250252
_disk->unmount();
251253
device_active = false;
254+
mount_time = 0;
252255
}
253256
}
254257

@@ -308,4 +311,4 @@ void rs232Disk::rs232_process(uint32_t commanddata, uint8_t checksum)
308311
rs232_nak();
309312
}
310313

311-
#endif /* BUILD_RS232 */
314+
#endif /* BUILD_RS232 */

lib/device/rs232/disk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class rs232Disk : public virtualDevice
2121
void dump_percom_block();
2222

2323
public:
24+
time_t mount_time = 0;
25+
2426
rs232Disk();
2527
mediatype_t mount(FILE *f, const char *filename, uint32_t disksize, mediatype_t disk_type = MEDIATYPE_UNKNOWN);
2628
void unmount();

lib/device/rs232/fuji.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,24 @@ void rs232Fuji::rs232_status()
8888
{
8989
Debug_println("Fuji cmd: STATUS");
9090

91-
char ret[4] = {0};
91+
if (cmdFrame.aux1 == STATUS_MOUNT_TIME_L && cmdFrame.aux2 == STATUS_MOUNT_TIME_H)
92+
{
93+
// Return drive slot mount status: 0 if unmounted, otherwise time when mounted
94+
time_t mount_status[MAX_DISK_DEVICES];
95+
int idx;
96+
9297

93-
bus_to_computer((uint8_t *)ret, sizeof(ret), false);
98+
for (idx = 0; idx < MAX_DISK_DEVICES; idx++)
99+
mount_status[idx] = _fnDisks[idx].disk_dev.mount_time;
100+
101+
bus_to_computer((uint8_t *) mount_status, sizeof(mount_status), false);
102+
}
103+
else
104+
{
105+
char ret[4] = {0};
106+
107+
bus_to_computer((uint8_t *)ret, sizeof(ret), false);
108+
}
94109
return;
95110
}
96111

@@ -1650,4 +1665,4 @@ std::string rs232Fuji::get_host_prefix(int host_slot)
16501665
return _fnHosts[host_slot].get_prefix();
16511666
}
16521667

1653-
#endif /* BUILD_RS232 */
1668+
#endif /* BUILD_RS232 */

lib/device/rs232/fuji.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#define READ_DEVICE_SLOTS_DISKS1 0x00
2424
#define READ_DEVICE_SLOTS_TAPE 0x10
2525

26+
#define STATUS_MOUNT_TIME_L 0x01
27+
#define STATUS_MOUNT_TIME_H 0x00
28+
2629
typedef struct
2730
{
2831
char ssid[33];
@@ -148,4 +151,4 @@ class rs232Fuji : public virtualDevice
148151

149152
extern rs232Fuji theFuji;
150153

151-
#endif // FUJI_H
154+
#endif // FUJI_H

0 commit comments

Comments
 (0)