完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
原子大哥以及各位同行高手,我现在做一个项目,目的在STM32F439平台上,把SD卡里面的文件上传到指定服务器。目前已经移植好LWIP协议栈,能ping通板子,并且移植了官方的tftpserver.c文件,先在想通过tftp协议上传文件到指定服务器。各位谁有这方面经验,请假一下。
目前想的方法是: 第一步:用tftpserver.c中的err_t tftp_send_message(struct udp_PCB *upcb, struct ip_addr *to_ip, int to_port, char *buf, int buflen)向指定地址发送写文件请求; 第二步:用tftpserver.c中的void process_tftp_request(struct pbuf *pkt_buf, struct ip_addr *addr, u16_t port)函数处理回应,如果接收到回应后,process_tftp_request函数中的int tftp_process_write(struct udp_pcb *upcb, struct ip_addr *to, int to_port, char *FileName)函数发送数据文件。 基本流程就是上述所说,但是tftp_send_message()函数中的参数struct udp_pcb *upcb,数据结构非常复杂 struct udp_pcb { /* Common members of all PCB types */ IP_PCB; /* Protocol specific PCB members */ struct udp_pcb *next; u8_t flags; /* ports are in host byte order */ u16_t local_port, remote_port; #if LWIP_IGMP /* outgoing network interface for multicast packets */ struct ip_addr multicast_ip; #endif /* LWIP_IGMP */ #if LWIP_UDPLITE /* used for UDP_LITE only */ u16_t chksum_len_rx, chksum_len_tx; #endif /* LWIP_UDPLITE */ /* receive callback function * addr and port are in same byte order as in the pcb * The callback is responsible for freeing the pbuf * if it's not used any more. * * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf * makes 'addr' invalid, too. * * @param arg user supplied argument (udp_pcb.recv_arg) * @param pcb the udp_pcb which received data * @param p the packet buffer that was received * @param addr the remote IP address from which the packet was received * @param port the remote port from which the packet was received */ void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port); /* user-supplied argument for the recv callback */ void *recv_arg; }; 不知道怎么向这个结构体指针传参数? 并且一般FTP传文件都要知道对方IP以及“用户名,密码”,可以这个发消息的结构体中没有涉及到“用户名,密码”方面。 谁有这方面的开发经验,请赐教,谢谢! |
|
相关推荐
4个回答
|
|
帮顶。。。。
|
|
|
|
请问有人解决这个发送文件的问题吗
|
|
|
|
因为这是TFTP,没有FTP里的那种用户验证。。。所以自然没有账户和密码
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
如何使用STM32+nrf24l01架构把有线USB设备无线化?
2339 浏览 7 评论
请问能利用51单片机和nRF24L01模块实现实时语音无线传输吗?
2088 浏览 5 评论
2786 浏览 3 评论
2532 浏览 8 评论
为什么ucosii上移植lwip后系统进入了HardFault_Handler?
2477 浏览 4 评论
546浏览 0评论
561浏览 0评论
328浏览 0评论
145浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-4-27 01:24 , Processed in 1.023088 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号