Thanks for the reply. Below is the code you requeted. Please note that I had this same trouble with Zaptel 1.2.7, but 1.2.6 works just fine.
}
/*
-
Direct/Indirect
-
v
-
FF FF FF FF WD 06 1
-
^---------^ ^ Reg
-
| Write/Read
-
|
-
SLIC #
*/
static int parse_slic_cmd(const char *buf, slic_cmd_t *sc, slic_reply_t requested_reply)
{
char op; / [W]rite, [R]ead /
char reg_type; / [D]irect, [I]ndirect */
int s1, s2, s3, s4;
int reg_num;
int data_low, data_high;
xpp_line_t lines;
int ret;
ret = sscanf(buf, “%x %x %x %x %c%c %x %x %x”,
&s1, &s2, &s3, &s4, &op, ®_type, ®_num, &data_high, &data_low);
lines = (s4 << 24) | (s3 << 16) | (s2 << 8) | (s1);
switch(op) {
case ‘R’:
if(reg_type == ‘D’ && ret == 7) {
// DBG(“0x%X 0x%X 0x%X 0x%X %c %x\n”, s1, s2, s3, s4, reg_type, reg_num);
ret = slic_cmd_direct_read(sc, lines, reg_num);
if(requested_reply) {
requested_reply->indirect = 0;
requested_reply->reg_num = reg_num;
}
} else if(reg_type == ‘I’ && ret == 7) {
// DBG(“0x%X 0x%X 0x%X 0x%X %c %x\n”, s1, s2, s3, s4, reg_type, reg_num);
ret = slic_cmd_indirect_read(sc, lines, reg_num);
if(requested_reply) {
requested_reply->indirect = 1;
requested_reply->reg_num = reg_num;
}
} else {
NOTICE("%s: Bad read input: ret=%d buf=’%s’ reg_type=%c\n", FUNCTION, ret, buf, reg_type);
goto err;
}
break;
case ‘W’:
if(reg_type == ‘D’ && ret == 8) {
// DBG(“0x%X 0x%X 0x%X 0x%X %c %x %X\n”, s1, s2, s3, s4, reg_type, reg_num, data_high);
ret = slic_cmd_direct_write(sc, lines, reg_num, data_high);
} else if(reg_type == ‘I’ && ret == 9) {
// DBG(“0x%X 0x%X 0x%X 0x%X %c %x %X %X\n”, s1, s2, s3, s4, reg_type, reg_num, data_high, data_low);
ret = slic_cmd_indirect_write(sc, lines, reg_num, data_low, data_high);
} else {
NOTICE("%s: Bad write input: ret=%d buf=’%s’ reg_type=%c\n", FUNCTION, ret, buf, reg_type);
goto err;
}
break;
default:
NOTICE("%s: Bad input: ret=%d buf=’%s’ op=%c\n", FUNCTION, ret, buf, op);
goto err;
}
return ret;
err:
return -EINVAL;
}
static int process_slic_cmdline(xpd_t *xpd, char *cmdline)
{
xbus_t *xbus;
struct FXS_priv_data *priv;
slic_cmd_t sc;
xpacket_t *pack;
char *p;
int len = strlen(cmdline);
BUG_ON(!xpd);
xbus = xpd->xbus;
priv = xpd->priv;
if((p = strchr(cmdline, '#')) != NULL) /* Truncate comments */
*p = '\0';
if((p = strchr(cmdline, ';')) != NULL) /* Truncate comments */
*p = '\0';
for(p = cmdline; *p && (*p == ' ' || *p == '\t'); p++) /* Trim leading whitespace */
;
if(*p == '\0')
return 0;
len = parse_slic_cmd(p, &sc, &priv->requested_reply);
if(len < 0)
return len;
if(!sc.lines) {
NOTICE("%s: no channels are marked. Skip.\n", __FUNCTION__);
return 0;
}
dump_slic_cmd("WRITE_SLIC", &sc);
XPACKET_NEW(pack, xbus, FXS, SLIC_WRITE, xpd->id);
RPACKET_FIELD(pack, FXS, SLIC_WRITE, slic_cmd) = sc;
pack->datalen = len;
packet_send(xbus, pack);
return 0;
}
static int proc_xpd_slic_write(struct file *file, const char __user *buffer, unsigned long count, void *data)
{
xpd_t *xpd = data;
const int LINE_LEN = 500;
char buf[LINE_LEN];
char *p;
int i;
int ret;
if(!xpd)
return -ENODEV;
for(i = 0; i < count; /* noop */) {
for(p = buf; p < buf + LINE_LEN; p++) { /* read a line */
if(i >= count)
break;
if(get_user(*p, buffer + i))
return -EFAULT;
i++;
if(*p == '\n' || *p == '\r') /* whatever */
break;
}
if(p >= buf + LINE_LEN)
return -E2BIG;
*p = '\0';
ret = process_slic_cmdline(xpd, buf);
if(ret < 0)
return ret;
mdelay(1);
}
return count;
}
int __init card_fxs_startup(void)
{
INFO("%s revision %s\n", THIS_MODULE->name, ZAPTEL_VERSION);
#ifdef POLL_DIGITAL_INPUTS
INFO(“FEATURE: %s with DIGITAL INPUTS support (%s activated)\n”,
THIS_MODULE->name, (poll_digital_inputs) ? “is” : “is not”);
#else
INFO(“FEATURE: %s without DIGITAL INPUTS support\n”, THIS_MODULE->name);
#endif
xproto_register(&PROTO_TABLE(FXS));
return 0;
}
void __exit card_fxs_cleanup(void)
{
xproto_unregister(&PROTO_TABLE(FXS));
}
MODULE_DESCRIPTION(“XPP FXS Card Driver”);
MODULE_AUTHOR(“Oron Peled oron@actcom.co.il”);
MODULE_LICENSE(“GPL”);
MODULE_VERSION(ZAPTEL_VERSION);
MODULE_ALIAS_XPD(XPD_TYPE_FXS);
module_init(card_fxs_startup);
module_exit(card_fxs_cleanup);