RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-16574

eri's questions

Martin Hope
eri
Asked: 2024-12-13 15:29:02 +0000 UTC

将 C 文件链接到 CPP

  • 5

我从这里为我的代码(.h 和 .c)获取了 2 个文件https://github.com/christhechris/libscrc/blob/master/src/_crc16tables.h 并将其放入文件夹中

cmake 没有链接

add_executable(mycode main.cpp crc/_crc16tables.c )

有错误

 undefined reference to `hz_calc_crc16_1021(unsigned char const*, unsigned int, unsigned short)'

但如果你将文件重命名为cpp,它就可以正常工作。

如何正确链接c到cpp?

c++
  • 1 个回答
  • 66 Views
Martin Hope
eri
Asked: 2024-08-16 19:25:09 +0000 UTC

为 python 类型创建哈希

  • 6

我们假设以下结构:

class Base:
  id = 0

  def __type_hash__(cls):
    return hash((Base,cls.id))

  def __init__(self,value)
    self.value = value

  def __hash__(self):
    return hash(value)

class C87(Base):
  id = 0x87

class CA0(C87):
  id = 0xA0

class CFoo(C87):
  pass

class CBar(CA0):
  pass

例如,我想在列表和键中使用该类

C87 in [CFoo] == True
CFoo in [Base, CA0] == False

__type_hash__- 未知魔法的占位符。实例应按值进行比较,类应按 id 进行比较。

python
  • 1 个回答
  • 62 Views
Martin Hope
eri
Asked: 2024-01-10 22:06:30 +0000 UTC

Android Studio Flutter Linux 设置安装前缀用于调试

  • 5

我通过Android Studio中的向导创建了一个项目。当您尝试启动或调试时,它会尝试将可执行文件安装在 /usr/local/ 中,但我想避免这种情况。

Launching lib/main.dart on Linux in debug mode...
Building Linux application...
CMake Error at cmake_install.cmake:66 (file):
  file INSTALL cannot copy file
  "/mnt/home/eri/Projects/2024/HELLO/flutterhello/build/linux/x64/debug/intermediates_do_not_run/flutterhello"
  to "/usr/local/flutterhello": Permission denied.


Exception: Build process failed

如何配置项目来构建而不出现此错误?

linux
  • 1 个回答
  • 14 Views
Martin Hope
eri
Asked: 2023-12-14 07:15:39 +0000 UTC

如何更新 1c 的 Postgres 数据库?

  • 5

如何正确升级Postgresql 9.6到14。通过SQL传输数据库时,启动客户端时出现错误:

2023-12-13 23:01:09.787 UTC [18208] ERROR:  CREATE EXTENSION ... FROM is no longer supported at character 52
2023-12-13 23:01:09.787 UTC [18208] STATEMENT:  create extension if not exists mchar schema public FROM unpackaged

使用1C卸载数据库并将其加载到新数据库中?

postgresql
  • 2 个回答
  • 30 Views
Martin Hope
eri
Asked: 2023-10-08 19:49:46 +0000 UTC

键入和未分配的值

  • 6

如何表示不能赋值的变量的类型?

您需要确认在yield 中发送的最后一个命令。

import asyncio

class Cmd1():
    value = 1

q = asyncio.Queue()
q.put_nowait(Cmd1())
q.put_nowait(Cmd1())


def ack(cmd):
    print(cmd)


async def gena():
    cmd = None
    try:
        while True:
           cmd = await q.get()
           print(cmd)
           yield cmd.value
    finally:
        if cmd :
            ack(cmd)


async def main():
    async for cmd in gena():
        break

asyncio.run(main())  

如果您这样做,cmd: Cmd1|None = None它会以红色突出显示cmd.value。如果cmd: Cmd1那样我就不能分配 None 。

"value" is not a known member of "None" Pylance report OptionalMemberAccess

如何指定cmd类型以便测试通过而不使运行时复杂化?

或者如何重写这个结构?

目前是这样的:

async def gena():
    cmd = None # type: ignore
    try:
        while True:
           cmd : Cmd1 = await q.get()
           print(cmd)
           yield cmd.value
    finally:
        if cmd :
            ack(cmd)
python
  • 2 个回答
  • 52 Views
Martin Hope
eri
Asked: 2023-07-17 03:43:03 +0000 UTC

将签名合并到一条加密消息中

  • 6

不同的人为同一文件创建了多个签名。如何从多个文件中收集一个文件?也许通过 asn1crypto 或其他什么?

openssl pkcs7 -in q.sig -in w.sig -out all.sig 

没有滚。

python
  • 1 个回答
  • 41 Views
Martin Hope
eri
Asked: 2022-12-23 16:26:16 +0000 UTC

在不写入磁盘的情况下运行 elf 应用程序

  • 7

有一个go编译的二进制可执行文件。我正在制作一个启动它的主管程序(现在是 fork+execv)。

但是是否可以在不写入磁盘的情况下从字节数组运行它?

如果不是,是否可以在没有名称的情况下启动文件描述符?对 tmpfile 的调用使 readlink 说该文件已被删除。是否可以通过打开描述符或 inode 编号运行?这里的问题就出现了,文件是打开写的,关闭的时候打不开,因为会被彻底删除。

对于这种情况,如果您使用 mkstemp 打开文件,一切正常,但使用 tmpfile

#include "bin.h"
#include <unistd.h>
#include <stdio.h>
// #include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>

#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>

int main(int argc, char *argv[], char *envp[])
{
    int r;
    FILE *tmp = tmpfile();
    int fd = fileno(tmp);
    write(fd, __bin, __bin_len);
    fsync(fd);
    fchmod(fd, S_IRWXU);
    FILE *tmp2 = fdopen(fd, "r");
    fclose(tmp);
    fd = fileno(tmp2);
    pid_t pid;
    switch (pid = fork())
    {
    case -1:
        perror("fork");
        exit(1);        
    case 0:
        getppid();
        //fclose(tmp2);
        return 0;
    default:
        return fexecve(fd, argv, envp);
    }
    return 1;
}

这样的流浪

.....
openat(AT_FDCWD, "/tmp", O_RDWR|O_EXCL|O_TMPFILE, 0600) = 3
fcntl(3, F_GETFL)                       = 0x418002 (flags O_RDWR|O_LARGEFILE|O_TMPFILE)
getrandom("\xc1\x83\x35\x01\xbe\xec\x96\x5a", 8, GRND_NONBLOCK) = 8
brk(NULL)                               = 0x55c875ae0000
brk(0x55c875b01000)                     = 0x55c875b01000
write(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360d\0\0\0\0\0\0"..., 352808) = 352808
fsync(3)                                = 0
fchmod(3, 0700)                         = 0
fcntl(3, F_GETFL)                       = 0x418002 (flags O_RDWR|O_LARGEFILE|O_TMPFILE)
close(3)                                = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f6e46e76910) = 348850
execveat(3, "", ["./nano"], 0x7ffe01dcd068 /* 60 vars */, AT_EMPTY_PATH) = -1 EBADF (Неправильный дескриптор файла)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=348850, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
exit_group(-1)                          = ?
+++ exited with 255 +++

附言 “bin.h”通过xxd -i /bin/nano > ./bin.h

linux
  • 1 个回答
  • 40 Views
Martin Hope
eri
Asked: 2022-08-23 18:24:13 +0000 UTC

如何为www和用户制作正确的acl?

  • 2

如何使 acl 递归地应用于子目录和文件?

这样做的同时

setfacl -Rm u:user:rwX,u:www-data:rwX /var/www/html/

但新文件可能会以错误的权限出现。

# owner: siter
# group: siter
user::rw-
group::r-x          #effective:r--
group:www-data:rwx      #effective:rw-
mask::rw-
other::r--

虽然团子卡住了...

如何执行类似于复选框“用从该对象继承的权限条目替换子对象的所有权限条目”窗口的操作?

在此处输入图像描述

linux acl
  • 1 个回答
  • 19 Views
Martin Hope
eri
Asked: 2022-07-01 01:36:44 +0000 UTC

以非现金付款方式检查

  • 0

与嵌入式设备的集成问题

我将商品“测试”发送到结帐数量 1 价格 1:

024a ff46 01000000 01 e80300000000 6400000000 ffffffffff ffffffffff 00 00 01 04 f2e5f1f22000000000000000000000000000000000000000000000000000000000000000000000000000 4d

结帐响应 - 好的: ff46 00

以无现金支付关闭 0249 85 01000000 0000000000 6400000000 0000000000 0000000000 0000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 a9

收银员回应“关闭支票:非现金支付的金额大于支票金额” 85 4d

帮助我理解。

касса
  • 0 个回答
  • 0 Views
Martin Hope
eri
Asked: 2022-06-28 22:31:26 +0000 UTC

以编程方式拉伸 STL 模型

  • 0

现在有条件地有一个模型“AAAAAAAAA”。它必须在“AAABBBVVV”上标上一些东西,并用它制作模型“AAABBBVVV”和“AAABBBBBVVV”。(其中 A、B、C 是三角形组)。也就是说,区域 A 保留几何形状,区域 B 被拉伸和压缩,区域 C 在保持几何形状的同时移动。结果必须是单个对象。

在此处输入图像描述

你能告诉我如何以编程方式实现它吗?应该使用什么格式来存储点组标签?哪些程序将对此有所帮助?

模型可以手工切割成碎片,但如何将它们粘在一起以形成一个整体?

3d моделирование
  • 2 个回答
  • 35 Views
Martin Hope
eri
Asked: 2022-09-07 21:23:15 +0000 UTC

CCP预付款

  • 1

下列情况如何正确生成收银台单据?这可以在一次检查中完成吗?

部分付款与货物的转移 - 付款金额少于文件的金额。如果我设置“赊销”操作并在单据中添加付款,支票会通过吗?

文件上的多付:我在多付的金额和预付款的符号上添加了一行。如何在下一笔交易中正确抵消这笔预付款?

操作通过新格式传递https://github.com/alex-eri/pyshtrih/blob/84fe546bd141b92c5e66c7f35a6969e38d405d18/pyshtrih/commands.py#L869

python
  • 1 个回答
  • 10 Views
Martin Hope
eri
Asked: 2022-08-31 19:20:43 +0000 UTC

exit 在有条件的脚本中不起作用

  • 1
#!/bin/bash
[ "x$(tail -n+11 $0 | md5sum)" = "x$(head -n10 $0 | tail -n1)" ] || (echo "поврежден"; exit 1);

echo "corrupted" 写入,但退出 1 不起作用。如何重写才能工作?

linux
  • 1 个回答
  • 10 Views
Martin Hope
eri
Asked: 2022-08-27 15:55:41 +0000 UTC

linux中的kerio vpn客户端

  • 2

连接成功,但是给kvnet接口分配了错误的mac地址。服务器的响应来自另一个罂粟。

要求

Ethernet II, Src: e2:75:42:f6:d7:11 (e2:75:42:f6:d7:11), Dst: Microsoft_53:01:00 (44:45:53:53:01:00)
Internet Protocol Version 4, Src: 10.253.38.21, Dst: 10.253.38.1

回答

Ethernet II, Src: Microsoft_53:01:00 (44:45:53:53:01:00), Dst: 3a:04:ca:08:75:27 (3a:04:ca:08:75:27)
Internet Protocol Version 4, Src: 10.253.38.1, Dst: 10.253.38.21
linux
  • 1 个回答
  • 10 Views
Martin Hope
eri
Asked: 2022-08-05 22:28:28 +0000 UTC

如何从对象中的 SVG 执行 HTML js 函数?

  • 2
 <object
  type="image/svg+xml"
  data="display.svg">

 <script type="text/javascript">
   function hop(name, evt) {
        console.log('!!!')
   }
 </script>

或者如何将脚本注入对象?

目标是<path>通过参数evt.target或至少id在主框架的js中获得点击。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
eri
Asked: 2022-04-05 23:47:43 +0000 UTC

我如何知道 HDMI 连接器是否支持 CEC?

  • 2

在电视侧面可以找到菜单。但是在重新编译Linux之前,如何确定显卡是否支持该协议呢?

linux
  • 1 个回答
  • 10 Views
Martin Hope
eri
Asked: 2022-03-15 18:06:55 +0000 UTC

如何修补 live555 以获得更小的 rtp 大小?

  • 1

第二个小时我试图弄清楚live555。我将设备上的 MTU 降低到 1400,但仍然发送数据包大小为 1496 的 rtp。我在代码中找不到减去 rtp 中的缓冲区的地方。

linux
  • 1 个回答
  • 10 Views
Martin Hope
eri
Asked: 2021-12-20 01:26:19 +0000 UTC

将类方法传递给另一个方法和QMap,c ++

  • 1
class XM : public QObject
{
    Q_OBJECT

public:
    explicit XM(  QObject *parent = nullptr);
    void login();

private:
    quint32 counter;
    typedef void(XM::*callback)(quint32);
    QMap<qint32, callback > commands;
    quint32 send(callback cb);
    void login_cb();

private slots:
    void ready();

};


void XM::login()
{
    this->send(&XM::login_cb);
}

quint32 XM::send(callback cb)
{
    // тут отправили задачу на сервер
    this->commands.insert(this->counter, cb);
    this->counter+=2;
}

void XM::ready(quint32 counter, quint32 data)
{
    // тут приняли ответ
    callback fut = this->commands.take(counter);
    fut(data);
}

void XM::login_cb(quint32 data)
{
    // тут нужен тот же this, что был в login
    qDebug() << data;
}

这是代码,如果你把所有的肉都扔掉。

错误

ошибка: called object type 'XM::callback' (aka 'void (XM::*)(quint32)') is not a function or function pointer
c++
  • 1 个回答
  • 10 Views
Martin Hope
eri
Asked: 2021-12-16 21:49:35 +0000 UTC

如何设置 dkms 忽略 -Wmisleading-indentation?

  • 0

该模块构建良好,但不与 dkms 一起安装。代码在这里https://github.com/alex-eri/ttypos.git

Unpacking ttypos-dkms (303-202012) over (20.12-11) ...
Setting up ttypos-dkms (303-202012) ...
Loading new ttypos-303 DKMS files...
It is likely that 5.4.81-1-lts belongs to a chroot's host
Building for 4.19.0-12-amd64
Building initial module for 4.19.0-12-amd64
Error!  Build of ttypos.ko failed for: 4.19.0-12-amd64 (x86_64)
Consult the make.log in the build directory
/var/lib/dkms/ttypos/303/build/ for more information.
dpkg: error processing package ttypos-dkms (--install):
 installed ttypos-dkms package post-installation script subprocess returned error exit status 7
Errors were encountered while processing:
 ttypos-dkms

/var/lib/dkms/ttypos/303/build/make.log

DKMS make.log for ttypos-303 for kernel 4.19.0-12-amd64 (x86_64)
Wed Dec 16 18:59:57 UTC 2020
make: Entering directory '/usr/src/linux-headers-4.19.0-12-amd64'
  CC [M]  /var/lib/dkms/ttypos/303/build/ttyPos.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /var/lib/dkms/ttypos/303/build/ttyPos.mod.o
  LD [M]  /var/lib/dkms/ttypos/303/build/ttyPos.ko
make: Leaving directory '/usr/src/linux-headers-4.19.0-12-amd64'

最好从 dkms 一侧进行修复。

linux
  • 1 个回答
  • 10 Views
Martin Hope
eri
Asked: 2021-11-03 07:43:44 +0000 UTC

使用 gstreamer 在 python 中将 h264 推送到 mp4

  • 1

我创建了一个管道:

def encoder(name):
    pipeline = Gst.Pipeline()

    audioin = Gst.ElementFactory.make("appsrc", "audioin")
    videoin = Gst.ElementFactory.make("appsrc", "videoin")
    h264parse = Gst.ElementFactory.make("h264parse", "h264")
    alaw = Gst.ElementFactory.make("rawaudioparse", "alaw")

    faac = Gst.ElementFactory.make("faac", "faac")
    mux = Gst.ElementFactory.make("mp4mux", "mux")
    filesink = Gst.ElementFactory.make("filesink", "fsink")
    filesink.set_property("location", name + ".mp4")

    videoin.set_property("caps", Gst.caps_from_string('video/x-h264,width=1920,height=1080,framerate=9/1,stream-format=(string)avc'))

    audioin.set_property("caps", Gst.caps_from_string('audio/x-alaw,channels=1,rate=8000'))

    pipeline.add(videoin)
    pipeline.add(audioin)
    pipeline.add(alaw)
    pipeline.add(faac)
    pipeline.add(h264parse)
    pipeline.add(mux)
    pipeline.add(filesink)

    audioin.link(alaw)
    videoin.link(h264parse)
    h264parse.link(mux)
    alaw.link(faac)
    faac.link(mux)
    mux.link(filesink)

    return pipeline, audioin, videoin


    pipeline, audioin, videoin = encoder('filename')

在这里,我从 reader.video、reader.audio 接收数据并将其推入缓冲区

async def convert(reader):
    async def readforever(stream, cb):
        while not stream.at_eof():
            cb(await stream.read(2048))

    def push(src):
        def pushbuffer(data):
            print(rotating(), len(data), '      ', end="\r", flush=True)
            buf = Gst.Buffer.new_allocate(None, len(data), None)
            buf.fill(0, data)
            src.emit('push-buffer', buf)
            return True
        return pushbuffer

    pipeline.set_state(Gst.State.PLAYING)
    print('started')
    await asyncio.gather(readforever(reader.video, push(videoin)), readforever(reader.audio, push(audioin)))

    videoin.emit("end-of-stream")
    audioin.emit("end-of-stream")
    print(pipeline)
    bus = pipeline.get_bus()

    print(await reader.picture.read())
    print(await reader.bort.read())
    print('eos')
    #bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.EOS) # зависает
    pipeline.set_state(Gst.State.NULL)

gstreamer 日志说数据已经到达,但文件中没有任何内容。

python
  • 1 个回答
  • 10 Views
Martin Hope
eri
Asked: 2020-09-30 16:30:57 +0000 UTC

Linux下如何在知道分区文件的情况下找出磁盘文件

  • 2

如何找到包含已知分区的磁盘?

比如我知道UUID,我能找到——除了把最后的数字删掉,/dev/sda1怎么才能找到路径呢?/dev/sda

节文件名不仅可以是sdX1, 还/dev/nvme0n1p1可以是/dev/loop1p1...

linux
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5