Skip to content

Commit a0bf887

Browse files
committed
[fn-network][adam] network_write()
1 parent 3f21345 commit a0bf887

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
11
#include <stdbool.h>
22
#include <stdint.h>
3+
#include <eos.h>
34
#include "fujinet-network.h"
5+
#include "fujinet-network-adam.h"
46

57
uint8_t network_write(char* devicespec, uint8_t *buf, uint16_t len)
68
{
7-
return 0;
9+
struct _w
10+
{
11+
uint8_t cmd;
12+
uint16_t len;
13+
uint8_t buf[1024];
14+
} w;
15+
16+
uint8_t u = network_unit_adamnet(devicespec);
17+
18+
if (!u)
19+
return FN_ERR_NO_DEVICE;
20+
21+
w.cmd = 'W';
22+
23+
while (len)
24+
{
25+
w.len = (len > 1024) ? 1024 : len;
26+
memcpy(w.buf,buf,w.len);
27+
len -= w.len;
28+
29+
if (eos_write_character_device(u,w,w.len + 3) != ADAMNET_OK)
30+
return FN_ERR_IO_ERROR;
31+
}
32+
33+
return FN_ERR_OK;
834
}

0 commit comments

Comments
 (0)