MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / write_block

Function write_block

src/iofunc.c:1065–1169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1063 */
1064
1065int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
1066 size_t count)
1067{
1068 int ret;
1069
1070 if (p->fd < 0)
1071 {
1072 rig_debug(RIG_DEBUG_ERR, "%s: port not open\n", __func__);
1073 return (-RIG_EIO);
1074 }
1075
1076#ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY
1077
1078 if (p->post_write_date.tv_sec != 0)
1079 {
1080 signed int date_delay; /* in us */
1081 struct timeval tv;
1082
1083 /* FIXME in Y2038 ... */
1084 gettimeofday(&tv, NULL);
1085 date_delay = p->post_write_delay * 1000 -
1086 ((tv.tv_sec - p->post_write_date.tv_sec) * 1000000 +
1087 (tv.tv_usec - p->post_write_date.tv_usec));
1088
1089 if (date_delay > 0)
1090 {
1091 /*
1092 * optional delay after last write
1093 */
1094 hl_sleep(date_delay);
1095 }
1096
1097 p->post_write_date.tv_sec = 0;
1098 }
1099
1100#endif
1101
1102 if (p->write_delay > 0)
1103 {
1104 int i;
1105
1106 for (i = 0; i < count; i++)
1107 {
1108 ret = port_write(p, txbuffer + i, 1);
1109
1110 if (ret != 1)
1111 {
1112 rig_debug(RIG_DEBUG_ERR,
1113 "%s():%d failed %d - %s\n",
1114 __func__,
1115 __LINE__,
1116 ret,
1117 strerror(errno));
1118
1119 return -RIG_EIO;
1120 }
1121
1122 if (p->write_delay > 0) { hl_usleep(p->write_delay * 1000); }

Callers 15

tapr_cmdFunction · 0.85
dra818_setgroupFunction · 0.85
dra818_setvolumeFunction · 0.85
dra818_openFunction · 0.85
dra818_get_dcdFunction · 0.85
barrett_transaction2Function · 0.85
barrett_transactionFunction · 0.85
barrett_set_levelFunction · 0.85
wj_transactionFunction · 0.85
simplecat_transactionFunction · 0.85
quisk_transactionFunction · 0.85
netrigctl_transactionFunction · 0.85

Calls 5

rig_debugFunction · 0.85
gettimeofdayFunction · 0.85
port_writeFunction · 0.85
hl_usleepFunction · 0.85
dump_hexFunction · 0.85

Tested by

no test coverage detected