Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion msdos/src/fn_network/network_close.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ uint8_t network_close(const char* devicespec)
{
uint8_t device = network_unit(devicespec) + 0x70;

return int_f5(device,'C',0x00,0x00) == 'C';
return int_f5(device,'C',0x00,0x00) == 'C' ? FN_ERR_OK : FN_ERR_IO_ERROR;
}
15 changes: 15 additions & 0 deletions msdos/src/fn_network/network_error.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdbool.h>
#include <stdint.h>
#include <fujinet-network.h>
#include <fujinet-fuji-msdos.h>
#include <string.h>

uint8_t network_error(const char *devicespec)
{
uint8_t err = 0;
uint8_t status_ret = 0;

status_ret = network_status(devicespec, NULL, NULL, &err);

return status_ret;
}
2 changes: 1 addition & 1 deletion msdos/src/fn_network/network_http_set_channel_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
uint8_t network_http_set_channel_mode(const char *devicespec, uint8_t mode)
{
uint8_t device = network_unit(devicespec) + 0x70;
return int_f5(device,'M',0x00,mode) == 'C';
return int_f5(device,'M',0x00,mode) == 'C' ? FN_ERR_OK : FN_ERR_IO_ERROR;
}
12 changes: 6 additions & 6 deletions msdos/src/fn_network/network_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ uint8_t network_ioctl(uint8_t cmd, uint8_t aux1, uint8_t aux2, const char* devic
uint8_t *dbuf = NULL;
uint16_t dbyt = 0;
uint8_t ret = 0;

va_start(ap,devicespec);

if (ap)
dstats = va_arg(ap, uint8_t);
if (ap)
Expand All @@ -27,11 +27,11 @@ uint8_t network_ioctl(uint8_t cmd, uint8_t aux1, uint8_t aux2, const char* devic
va_end(ap);

if (dstats == 0x00)
ret = int_f5(device,cmd,aux1,aux2) == 'C';
ret = int_f5(device,cmd,aux1,aux2) == 'C' ? FN_ERR_OK : network_error(devicespec);
else if (dstats == 0x40) // Payload to computer
ret = int_f5_read(device,cmd,aux1,aux2,dbuf,dbyt);
ret = int_f5_read(device,cmd,aux1,aux2,dbuf,dbyt) == 'C' ? FN_ERR_OK : network_error(devicespec);
else if (dstats == 0x80) // Payload to fujinet
ret = int_f5_write(device,cmd,aux1,aux2,dbuf,dbyt);
ret = int_f5_write(device,cmd,aux1,aux2,dbuf,dbyt) == 'C' ? FN_ERR_OK : network_error(devicespec);

return ret;
}
2 changes: 1 addition & 1 deletion msdos/src/fn_network/network_json_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ uint8_t network_json_parse(const char *devicespec)
// Ask FujiNet to parse JSON.
ret = int_f5(device,'P',0x00,0x00);

return ret;
return ret == 'C' ? FN_ERR_OK : FN_ERR_IO_ERROR;
}
4 changes: 2 additions & 2 deletions msdos/src/fn_network/network_json_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int16_t network_json_query(const char *devicespec, const char *query, char *s)
// Perform query
ret = int_f5_write(device,'Q',0x00,0x00,(void *)query,256);
if (ret != 'C')
return ret;
return -1;

// Get # of bytes waiting
network_status(devicespec,&bw,&c,&err);
Expand All @@ -33,7 +33,7 @@ int16_t network_json_query(const char *devicespec, const char *query, char *s)
}
s[bw - offset] = '\0';
}

// return the string length (minus any trailing EOL char)
return bw - offset;
}
4 changes: 2 additions & 2 deletions msdos/src/fn_network/network_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
uint8_t network_open(const char* devicespec, uint8_t mode, uint8_t trans)
{
uint8_t device = network_unit(devicespec) + 0x70;
return int_f5_write(device,'O',mode,trans,devicespec,256);

return int_f5_write(device,'O',mode,trans,devicespec,256) == 'C' ? FN_ERR_OK : network_error(devicespec);
}
2 changes: 1 addition & 1 deletion msdos/src/fn_network/network_read_msdos.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ int network_read_msdos(char* devicespec, unsigned char *buf, unsigned int len)
{
uint8_t device = network_unit(devicespec) + 0x70;

return int_f5_read(device,'R',len&0xFF,len>>8,(void *)buf,len) == 'C';
return int_f5_read(device,'R',len&0xFF,len>>8,(void *)buf,len) == 'C' ? len : FN_ERR_IO_ERROR;
}
4 changes: 2 additions & 2 deletions msdos/src/fn_network/network_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
uint8_t network_write(const char* devicespec, const uint8_t *buf, uint16_t len)
{
uint8_t device = network_unit(devicespec) + 0x70;
return int_f5_write(device,'W',len&0xFF,len>>8,(void *)buf,len) == 'C';

return int_f5_write(device,'W',len&0xFF,len>>8,(void *)buf,len) == 'C' ? len : FN_ERR_IO_ERROR;
}
2 changes: 2 additions & 0 deletions msdos/src/include/fujinet-fuji-msdos.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ unsigned char int_f5(unsigned char dev, unsigned char command, unsigned char aux
unsigned char int_f5_read(unsigned char dev, unsigned char command, unsigned char aux1, unsigned char aux2, void *buf, unsigned short len);
unsigned char int_f5_write(unsigned char dev, unsigned char command, unsigned char aux1, unsigned char aux2, const void *buf, unsigned short len);

unsigned char network_error(const char *devicespec);

#endif /* FUJINET_FUJI_MSDOS_H */