C++ 中作用域受限的枚举类型

本文介绍 C++ 中传统枚举类型存在的作用域不受限等问题,随后列举经典的限定其作用域的做法,最后给出新标准 C++11 下的解决方案。

传统行为

传统的枚举类型在 C 语言中就有,C++ 中行为和 C 中一致,常被用来定义有类型的常量。一个典型的枚举类型定义如下:

enum Color { RED, BLUE };

C++ 发明人 Bjarne Stroustrup 总结这种枚举有如下问题

  • 作用域不受限 (unscoped),枚举变量的作用域不受限,会暴露给领近的代码作用域(如果在最外层则为全局作用域),容易引起命名冲突。例如如下代码是无法编译通过的:

    enum Color { RED, BLUE };
    enum Feeling { EXCITED, BLUE };
  • 会隐式转换为 int。这是 C 中的默认行为,但是和“有类型的常量”的初衷是不符合的。比如上面例子中 EXCITED == RED 会返回真(gcc 编译会有警告),这其实是不合常理的。

  • 用来表征枚举变量的实际类型不能明确指定,从而无法支持枚举类型的前向声明。

经典做法

解决作用域不受限带来的命名冲突问题的一个简单方法是,给枚举变量命名时加前缀,如上面例子改成 COLOR_BLUE 以及 FEELING_BLUE。一般说来,为了一致性我们会把所有常量统一加上前缀。但是这样定义枚举变量的代码就显得累赘。C 程序中可能不得不这样做。不过 C++ 程序员恐怕都不喜欢这种方法。替代方案是命名空间:

namespace Color { enum Type { RED, YELLOW, BLUE }; };

这样之后就可以用 Color::Type c = Color::RED; 来定义新的枚举变量了。如果 using namespace Color 后,前缀还可以省去,使得代码简化。不过,因为命名空间是可以随后被扩充内容的,所以它提供的作用域封闭性不高。在大项目中,还是有可能不同人给不同的东西起同样的枚举类型名。

更“有效”的办法是用一个类或结构体来限定其作用域,例如:

struct Color { enum Type { RED, YELLOW, BLUE }; };

定义新变量的方法和上面命名空间的相同。不过这样就不用担心类在别处被修改内容。这里用结构体而非类,一是因为本身希望这些常量可以公开访问,二是因为它只包含数据没有成员函数。

C++11 的枚举类

上面的做法解决了第一个问题,但对于后两个仍无能为力。庆幸的是,C++11 标准中引入了“枚举类”(enum class),可以较好地解决上述问题。它使用如下语法定义:

enum class Color { RED, BLACK };

可见语法更为简单了。如此一来,定义新变量也得到简化:

Color c = Color::RED;

类限制了其作用域,避免了命名冲突。同时也避免了隐式类型转换。也就是说,枚举类即是作用域受限的 (scoped),又是强类型的 (strongly typed) 枚举。至于第三个问题,C++11 标准允许指定存储类型:

enum class Color : char { RED, BLUE };

上面例子使用 char 来存储这个枚举类。缺省情况下使用 int。这样枚举就可以进行前向声明了:

enum class Color : char ;   // forward declaration
void foo (Color *p);
// ...
enum class Color : char { RED, BLUE }; // definition

有了前向声明,代码可以更好地组织到不同的文件里,增加程序可读性和可维护性。

更多参考

除了文中链接外,还有如下链接可供参考:

bladeRF 固件与 FPGA 注记

使用 bladeRF 板卡时我们会遇到两个“镜像”:固件 (firmware) 镜像与 FPGA 镜像。二者是两个不同的概念。但是业界叫法不一,有时候会把二者混为一谈。一般而言,固件指的是嵌入到硬件设备中的软件,存放在只读存储器 (ROM) 或者闪存 (flash) 中,一般不易修改,修改的操作称为“刷新”(flashing)。固件这个名词最初和微代码相关,不过 bladeRF 里源代码是嵌入式 C 程序。FPGA 全名为可编程门阵列,其门电路、寄存器连接可以编程重构,其源程序一般是硬件描述语言 (HDL),通过综合 (synthesis) 等步骤得到二进制文件。在 bladeRF 板卡上,FPGA 只是一块 Altera 芯片。在没有内置非挥发存储时,FPGA 镜像需要每次上电时重新加载,bladeRF 就是这种情况。所以在拿到板卡时,上面已有固件,但还没有 FPGA 镜像。下面本文会具体说明在使用 bladeRF 时如何刷新固件、加载/更新 FPGA 镜像、以及如何自动加载 FPGA 镜像。注意,有时为了避免混淆,会称 FPGA 镜像为 FPGA 比特流 (bitstream),或者 FPGA 配置(因为它就是配置了门电路等组件的连接)。

刷新固件

注意:刷新固件前请先取消 FPGA 自动加载,以避免可能的冲突。FPGA 自动加载的细节参见下文。

Nuand 官方提供固件的源码,我们可以自行编译,不过这需要一套嵌入式开发工具链。Nuand 也提供构建好的固件镜像,可以直接下载使用。要刷新固件,只需在命令行执行:

bladeRF-cli -f bladeRF_fw_vX.Y.Z.img -v verbose

其中 X.Y.Z 为具体的版本号。命令完成后,需要断电重启了 bladeRF。然后可以用 bladeRF-cli 工具检查:

$ bladeRF-cli -e version

  bladeRF-cli version:        0.11.1-git-c631100
  libbladeRF version:         0.16.2-git-c631100

  Firmware version:           1.7.1-git-ca697ee
  FPGA version:               Unknown (FPGA not loaded)

看下其中 Firmware version(固件版本)是否更新。

事实上,还有另外一种刷新固件的方法,是通过进入设备的启动加载 (Bootloader) 模式(类似 Android 的 Recovery),输入一些命令完成的。不过这种方式步骤繁琐,一般不推荐使用,建议在上述简单方法遇到错误时考虑采用。具体步骤参加维基

加载 FPGA 镜像

注意到上面的示例中,FPGA version(FPGA 版本)显示为 Unknown(未知),FPGA 未加载。目前 bladeRF 使用两种 FPGA。要加载正确的 FPGA 镜像,首先需要确定手头 bladeRF 板卡的 FPGA 尺寸。它可以根据当初购买的价格判断,但更靠谱的方法是使用命令行查看:

$ bladeRF-cli -i
bladeRF> info

  Serial #:                 4f977f01eec48f5068c2ee3aeba41ba9
  VCTCXO DAC calibration:   0x8b63
  FPGA size:                40 KLE
  FPGA loaded:              yes
  USB bus:                  4
  USB address:              5
  USB speed:                SuperSpeed
  Backend:                  libusb
  Instance:                 0

交互模式下用 info 命令,或者直接在命令行下 bladeRF-cli -e info,在输出中寻找 FPGA size,就可以看到 FPGA 尺寸信息。这里示例显示板卡使用 40 KLE FPGA。事实上,FPGA 尺寸还可以通过查看 FPGA 芯片上的 EP4CExxxF23C8N 字样中 xxx 的部分来获得。

Nuand 官方提供了预先构建的 FPGA 镜像,免除用户手工编译之苦。40 KLE FPGA 对应 hostedx40.rbf 文件,以此类推。要加载 FPGA 镜像,只需使用命令 bladeRF-cli -l /path/to/fpga/file,或者交互模式下 load fpga /path/to/fpga/file,其中 /path/to/fpga/file 为 FPGA 镜像所在路径。FPGA 镜像成功加载后,板卡上的三个 LED 灯会亮起,交互模式下 version 命令可以看到 FPGA 版本不再是未知。

不过,正如前文所说,每次重新加电后,FPGA 镜像都需要重新加载。下面说下如何自动加载 FPGA 镜像。

自动加载 FPGA 镜像

bladeRF 维基上提供了两种自动加载 FPGA 镜像的方法。第一种方法基于主机软件,libbladeRF 在打开设备时,会在如下目录自动搜索合适的 FPGA 镜像:

  • $HOME/.config/Nuand/bladeRF/
  • $HOME/.Nuand/bladeRF/
  • /etc/Nuand/bladeRF/
  • /usr/share/Nuand/bladeRF/

只需将下载的 FPGA 镜像文件放在上述目录之一(没有可以新建之),即可实现 FPGA 镜像的自动加载。

另一种方式是将 FPGA 镜像写入设备的 SPI 闪存。这种方式的好处是写入后就不再依赖主机,从而可以实现脱机运行。不过这种方式比较慢,加载 x40 镜像需要大约 4 秒钟。注意绝对不要在加载完成,三个 LED 灯亮起前试图使用设备。要使用这种方式,需要执行下面命令:

bladeRF-cli -L /path/to/fpga/file

一般说来,如果没有脱机工作的需求,还是推荐第一种自动加载方法。

前面提到,刷新固件时最好取消自动加载。对于第一种方法,只需把 FPGA 镜像文件临时移走。第二种方法,则需要执行命令 bladeRF-cli -L X,以擦除写入的 FPGA 镜像。

致谢

本工作由星天科技赞助。

COSCUP 2014 行记

今年 7 月 19–20 日,台湾的开源社区大会 COSCUP 2014 在台北召开。我有幸以演讲者的身份第一次参加到了活动当中,所见所闻颇丰。

缘起

什么时间第一次听说 COSCUP 我已经记不清楚了。可以确定的是 emily 在 4 月份的一次 IRC 会议里提起过。tonghui 应该也提到过若干次。在大家的口中,COSCUP 非常有趣,台湾人很有娱乐精神。于是在今年的 COSCUP 征集演讲时,我投了两个话题,最终很幸运有一个被接收。FUDCon 期间,Max 也极力推荐我去 COSCUP 体验一下,liangsuilong 特别提到和 zerng07 等位于台湾的 Fedora 社区成员会面交流,他们也会参加 COSCUP 活动。此外,我对台湾自由行盘算多时,这正好是一个顺道去台湾旅行的机会,而 COSCUP 时间正好和实验室假期安排一致。基于以上原因,我下定决心去参加 COSCUP,之后顺便台湾自由行,即使后来得知大会不提供机票住宿的报销。

第 0 天:7 月 18 日

北京–香港–台北

因为机票要自费,所以最终订了一个在香港中转一次的航班。去程是深夜出发,感谢宝哥开车送我去首都国际机场。安检时查出带的洗头膏和沐浴露超量(200 mL,超出 100 mL 限制),只能免费寄存在机场,等回程时取走。航班延误了大约两个小时,应该与香港方面的天气情况有关。延误使得到香港时已经天亮,于是在香港机场吃了早饭。VISA 信用卡不知为何用不了,而且没有预备港币,还好可以付人民币找港币。

到达台北桃园机场已经是中午时分。排队过边检、换台币,发现机场已经不办青壮卡了。我住宿订在南港安乐旅社,过去要先坐一个小时的巴士。赶上了 12 点多出发去南港的客运巴士,巴士报站的是标准的台湾男声,温文尔雅。巴士终点是南港展览馆,我还进去逛了逛,不过没看到什么展览,倒是有一个会场有许多日本人在聚会。出来后依着旅社事先给的路线提示寻找,不过第一次真的没找到。当时还没办手机卡,在机场没有注意到办卡地点,再去找就只能做一个小时后的一班巴士了。不过走着走着看到路边有个中华电信的营业厅,于是决定先把手机卡办了。办的十天不限流量的 3G 卡,要 500 新台币;另外为了能打电话发短信,又充了 100 新台币值,后来证明这个充多了用处不大。办卡的女生太温柔礼貌了,我刚等了十秒钟就跟我说让您久等了,这着实让我一惊。

有了手机卡,有了 3G 网络,Google 地图终于可以派上用场了。最终找到旅社时,感慨他们家的门面招牌太小太不起眼了。不过他们是一家正宗的国际青旅,条件设施相当不错。住下后的下午没有出门,主要是休息一下,另外上网预订了去花莲的火车票,查了去演讲者晚宴的路线。

演讲者晚宴

演讲者晚宴在钱唐村,从我住的地方可以坐捷运过去,我顺道办了悠游卡。出捷运后还要走一会儿,路上经过了诚品敦南店,还能望到 101 大楼。还没看到餐厅招牌,就已经看到了从上海前来参会的 Thomas Yao。后来得知这是一家上海菜馆,饭菜很不错,不过 Thomas 的心情很复杂。进门领了胸牌 (Badge),看到了 tonghui。在吃好喝好的同是,还认识了 COSCUP 主办方议程方面的组织者、大会主持人 Richard Lin,以及我的演讲所在分会场的主持人 Penk,见到了 PCManX, fourdollars 等大神。比较囧的是一开始把 g0v 的村长误认成了大妈,二人发型初看挺像的 XD 从晚宴回住处的途中,我去了国父纪念馆,近距离拍摄了 101 大楼。

第 1 天:7 月 19 日

COSCUP 正式活动于周末两天在中研院举行。周六我早起在住处附近吃过早饭后搭公车(大陆称公交)前往会场。刚开始搞错了方向,耽误了些时间,不过也了解到台湾的公车是需要摆手才会到站停车的。到会场后找到演讲者签到处,很快拿到了会议袋,内有一本议程册和一件 Polo 衫和若干宣传页。COSCUP 并行演讲有 7 个之多,人文馆一层楼的会议室装不下,以至于一半的演讲在另外一个楼,名叫学术活动中心。好在 keynote 时全场地联播,各个分会场都可以实时看到主会场的画面,能够有效地分流观众。我的演讲安排在学术活动中心的一个房间,并且就在 keynote 之后,所以我提前去那个楼了。

九点多些,活动正式开幕,Richard 是主持。他介绍今年参会一千多人,但门票开票后 10 秒钟就被抢光,可谓秒杀,COSCUP 受欢迎程度可见一斑。Richard 还指出 COSCUP 不仅仅是技术分享,更重要的是提供遇到社区中的人,和大家面对面交流的机会。之后是题为 Maker 《自造世代》的 keynote,但与传统形式有很大不同,这个 keynote 先是播放 Maker 电影片段,然后是主持人和电影团队、开源人士进行小组讨论 (panel discussion)。Maker 大陆翻译为创客,台湾翻译为自造者。Maker 和开源有许多关联,这也是主办方将今年主题定为 Make Things Happen 的原因。

keynote 行将结束时,我就前往 H3 会议室,准备我的演讲了。H3 是个小会议室,挺容易坐满的。我的主题是 Fedora.next: What’s Next?,开始前我先做了个小调查,发现在场听说过、用过 Fedora 的用户还不少。在演讲中我还是先简单介绍了 Fedora 项目及其四项基本点,然后介绍了 Fedora.next 这一架构提案的缘起、内容、以及当前进展情况。Fedora.next 目前仍是一个比较新的概念,这个演讲的主要目的是让中文社区的朋友更紧密地跟进说英语的核心社区,为社区未来发展做出更多更为核心的贡献。

问答环节有提问问到 Fedora 会不会有类似某些发行版那样的长期支持版 (LTS)。我的回答是目前看来没有。这和 Fedora 相对更追求新鲜特性 (Feature)、敢为人先 (First) 的特点有关。RHEL、CentOS 等 Fedora 衍生版则更多关注稳定性。历史上有一个 Fedora Legacy 项目来对旧版本的 Fedora 进行持续支持,不过后来因为缺乏人力和兴趣,已经不再继续。不过,最近的 Fedora 贡献者大会 Flock 2014 上,Fedora Workstation 工作组的 Christian Schaller 提到要打造真正的 ABI,这也许会在将来改善 Fedora 的长时稳定性。

反思这次演讲,稍稍有些超时,占用了部分问答时间,以后还是要精简要讲的内容。演讲使用中文普通话,即国语,在用词上依照了大陆的习惯,没有对项目/专案、软件/软体、社区/社群等稍加解释,可能会给台湾听众带来一定困难。

之后我发放了 Fedora 的小礼品——一些胸章和徽章 (pins and buttons)给现场听众。这些小礼品最初在欧洲生产,由 tuanta 带到越南,然后在 FUDCon 时寄到北京,再被我带到台湾,相当有纪念意义。我也受到了 COSCUP 给演讲者准备的礼物,是一个体验活字印刷的盒子,非常精美。值得一提的是,COSCUP 会让演讲者现场签一个授权协议,用 CC 协议授权自己的讲稿和录像。

茶歇时间,我找到 zerng07 等人,边聊天边逛展台(摊位)。大会展台巨多,分布在不同楼以及不同楼层。主办方搞起了所谓大地游戏,逛展台时刷自己的胸牌,然后刷够一定数量后可以领取一个礼品,这也刺激了大家逛展台的兴趣,增进了和不同社区交流讨论的机会。Mozilla、Ubuntu 等的台湾社区颇为壮大,展台布置地也很赞,礼品多多活动多多。来自大陆的赞助商 GitCafe 也有一个活跃的展台,不过他们需要和不太了解的观众解释他们不是卖咖啡的 :D。值得一提的是,一些赞助商看似和技术、开源没什么关系,却也在展台上兴致勃勃地卖茶、卖饮料,足见 COSCUP 已经辐射到传统的开源圈子以外,有着更广泛的关注和参与。在展台处碰到了 Max,顺利实现了 GNOME.Asia 视频的“人肉转运”。几天之后,Max 就把他们悉数上传到了 Youtube 上。

午餐由 COSCUP 统一提供,两个发放点,一千多人秩序井然地排队。队伍绕了整个楼层一周,据说排到了别的楼层,阵势丝毫不亚于清华电子系学生节排队。午餐就是大陆习惯称呼的盒饭,在台湾叫便当。菜品比较丰富,味道也不错。午饭时和大家聊,大家一致认为中研院是一个非常好的场地。事实上两年前的 COSCUP 也是在这里举办。饭后亲眼见到餐余垃圾的细致分类,印象深刻。

一天之中,除了茶歇和午餐,剩余时间主要就是赶场听报告了。在两层座位加过道都坐满了的大会议室里,PCMan 讲到 LXQt 是开源社区的成功合并 (merge) 而非分支 (fork),而他本人是个医生,开源只是业余爱好。法律专业老师葛冬梅为大家讲解如何确定开源项目的许可证信息,特殊情况该如何处理。Kito Cheng 生动地描述开源编译器,主要是 clang 和 gcc,之间的“竞赛”,所在的小会议室在开讲前就已爆棚。来自赞助商 Google 的演讲题目直到最后才揭晓,是由其工程师吴光哲介绍刚刚发布的 Noto Sans CJK 字体制作过程的点滴,中型会议室也是人满为患。下午最后一场,我听了高村长 (clkao) 的 g0v 村情咨文。

到了晚上,COSCUP 安排了分社区的 BoF(Bird of Feather,同类人聚会)环节,并且提供了皮萨可乐。我参加了 Fedora 社区的聚会,和台湾地区的 Fedora 中文用户边吃边聊。Fedora 在台湾的社区不大,影响力相对较小,成员都比较年轻,多为学生,发展新成员也较多依靠朋友推介,优点是有兴趣有热情方便组织活动,缺点是社区参与受学业影响较大。这一点和大陆的情况颇为类似。因为人数不多,人力有限,所以台湾社区成员的精力主要集中在中文字体、输入法、本地化等中文用户最关心的问题上。相比起来,大陆这边贡献更为多元。另外,虽然台湾社区成员也参与 Fedora 中文列表的讨论,但他们似乎主要通过 Fedora 中文用户组在 Facebook 上的社群页来在线交流,而大陆用户很少参与其中,这使得两边交流目前比较有限。希望今后两边能有更多交流,在台湾地区大家的活力能够让 Fedora 为更多的人所知所用。

BoF 结束后,Max 请我和 tonghui 去他们住处附近的宁夏夜市,体验台北小吃。最初我们大陆团计划去师大夜市,不过得知那里的夜市氛围已大不如前。宁夏夜市位于宁夏街,一条不长的街道,但路两边小吃店和小吃摊琳琅满目。Max 带我们体验了炒粉(?)、豆花、还有记不清名字的带馅丸子,我们纷纷表示很好吃,并未事先没有预留肚子表示遗憾。据了解,台北小吃可以吃到晚上两三点,相应地公车和捷运的末班也都较晚,不由感慨台湾人民夜生活之幸福。

结语

因为我在台湾要待的日期不多,所以周日我就没有参与 COSCUP 的活动,而是选择了台北一日游。不过单就这一天,COSCUP 已经给我留下了很深的感受。总体说来,COSCUP 作为一个社区大会,汇聚了许多台湾的开源社区,促进了社区成员之间的交流,已经显示出了对更广泛人群的吸引力。从演讲话题来讲,话题征集不只强调甚至一定程度上弱化技术,更为关注社区建设和发展。另外开源被赋予了更多的内涵和外延,除了传统的开源技术社区话题外,还有不少开放政府、开放数据的主题。台湾当地的演讲者参与开源大多是兴趣驱动,演讲幽默风趣、生动好玩,(据说闪电演讲都会各种表演乃至杂耍,)演讲效果自然上乘。相对于技术交流为主的演讲,COSCUP 更注重让大家通过面对面的机会交友和交流,这对社区的发展壮大是有益的。反观大陆,我以为还没有一个能和 COSCUP 相提并论的社区大会。上半年的 GNOME.Asia 和 FUDCon APAC 合办,是一次很好的经历,但是在参与社区的数目、活动规模等方面还有一定差距。这和活动本身定位有关系,毕竟他们本身面向的人群是自己社区,面向的地域是整个亚洲/亚太而非中国。COSCUP 的成功,也许得益于台湾地域较小,交通相对廉价,人民(这里主要是程序员)生活水平较高。不过这不是大陆地区(或者整个华语地区)没有如此社区大会的借口。COSCUP 在议程、志愿者、展台等方面为大陆的社区活动提供了可以借鉴的经验。在其帮助下,通过社区群策群力,相信大陆地区真正意义上的社区大会可以梦想成真。

FUDCon APAC 2014 Report

Note: This is a press style report of FUDCon APAC 2014, which summarizes the event highlights. Don’t miss the links to slides, videos, and photos!

FUDCon APAC 2014 was successfully held at Conference Center at New Main Building of Beihang University, Beijing, China during May 23 to 25, 2014. This year the event was held together with GNOME.Asia Summit, an annual conference for GNOME users and developers in Asia. It turns out to be a rather exciting experience of mutually beneficial cooperation of free and open source communities. In total, GNOME.Asia and FUDCon APAC 2014 attracted more than 500 registrants, and among them over 300 attended the event.

There were 52 speakers in total and among them 22 are for FUDCon. Thanks to the help with the community budget, many non-local speakers joined the event and made FUDCon Beijing a big gather up for the Fedora community. The speakers delivered a wide range of topics about free and open source technologies and communities presented in keynote speeches and five parallel tracks. Richard Stallman gave a keynote speech on Computing, Freedom, and Privacy, which is the favorite speech according to the feedback survey. Talks in FUDCon tracks cover various subprojects of Fedora, as well as new application introduction and community building discussion. The links to all slides are available at the wiki page. As for the videos, they are currently available at the GNOME.Asia channel on Youtube. The Fedora Videos team is working to make them available on Fedora channel.

There were about 50 volunteers at the event. They were recruited from the local universities and companies. They showed great enthusiam and did amazing jobs to make the event well organized. Two of them, Tong Hui from GNOME and Zamir Sun from Fedora, were each awarded the prize of best volunteer, a hand fan full of wishes in various languages written by the attendees.

It is worth pointing out that about ten percent of the attendees are women. Many of them are active volunteers and talented speakers. Still more women contributors are expected in free and open source communities. And there was a dedicated session, Fedora Women initiated by Nitesh, to discuss the issue and possible solutions.

FUDCon is not just about technical sessions. It is also about meeting friends and having fun. FUDPub was organized as a welcome party, and there was a celebration party with delicious buffet on Sunday evening. On Saturday there were sports games including football, baseketball, and ping-pong. These social events helped the attendees enjoy the conference and the community.

Special thanks go to the sponsors. FUDCon was sponsored by 7 companies and 5 local communities. The success would be impossible without their generous support. There were 14 booths for sponsoring companies and local communities at the joint event. Attendees enjoyed hanging around the booths for discussion, and many swags were distributed at the booths.

Photos and Reports from various attendees are aggregated on the wiki page. The FUDCon Beijing Badge has been created and is in the process of collecting FAS usernames at the current writing.

DSC04041

Fedora 上搭建 bladeRF 环境

bladeRF 维基上介绍了在 Linux 系统上搭建 bladeRF 环境的步骤,不过原文是英文的,另外其中一些具体选择不尽合理。本文以 Fedora 系统为示例,提供一个中文版的 bladeRF 环境搭建指南,并着重介绍和维基上的不同点。比较可能有一定的时效性,但一些原则应该足够通用。本文的比较基准是当前的维基版本

安装依赖

维基上建议安装 “Development Tools” “Development Libraries” 两个软件包组,但我们只需要其中的一部分软件包,其中有些可能已经安装过了,而像 cvs 等并不必须。如果你像我一样有“洁癖”,不希望安装不需要的软件包,那么可以用如下的命令安装必须的依赖(未严格验证,在我这里绝大多数包都在之前安装过了):

sudo yum install git doxygen gettext glibc-devel ncurses-devel readline-devel zlib-devel boost-devel
sudo yum install libusbx libusbx-devel cmake wget gcc-c++

注意其中是 libusbx 而非 libusb,后者是 0.x 系列的版本,而非 1.x 系列。Debian/Ubuntu 系的用户会注意到软件包命名上的差异 (devel 而非 dev)。

维基上推荐安装 libtecla,以增强 bladeRF-cli 交互模式的编辑功能。不过 Fedora 软件源里目前还没有这个包,所以需要手动下载,解压缩,使用经典的 ./configure; make; sudo make install 三部曲安装。

构建 bladeRF

在终端下进入打算用来放置 bladeRF 源码的目录,用 git 将 bladeRF 的源码库克隆下来:

cd /path/to/bladeRF/directory
git clone https://github.com/Nuand/bladeRF.git

切换到源码目录中的 host 目录,创建一个 build 目录用来存放构建过程的中间文件。这种使用单独的构建目录的方式称为树外构建 (out of tree build),相对于直接在源码目录构建,好处在于生成的中间文件不会分散在源码目录里,方便清理,另外可以用多个构建目录构建出互不干扰的不同参数下的版本。之后切换到构建目录,然后就是标准的 cmake ..; make; sudo make install 三部曲了。注意这里 cmake 时启用了 INSTALL_UDEV_RULES 宏,使得安装时把 udev 规则文件也安装到系统中。

cd bladeRF/host/
mkdir build
cd build
cmake -DINSTALL_UDEV_RULES=ON ../
make
sudo make install

很遗憾的是这里安装的 udev 规则文件使用了 plugdev 群组,不是 Fedora 下的标准做法。可以参考之前的博文修改 udev 规则文件。

为了让新安装的 bladeRF 库文件可以被二进制文件使用,我们需要用 ldconfig 刷新系统动态库的缓存。上面的构建过程会将 bladeRF 安装到 /usr/local 下,而其中的库文件目录 /usr/local/lib{,64} 不在 ldconfig 的默认搜索路径里。所以我们可以将它们添加到 /etc/ld.so.conf 里。添加之后文件内容如下:

/usr/local/lib
/usr/local/lib64
include ld.so.conf.d/*.conf

之后,用 sudo ldconfig 刷新缓存即可。可以用 ldd /usr/local/bin/bladeRF-cli 命令检查 bladeRF 库文件是否被找到。连上 bladeRF 设备,用 bladeRF-cli -p 命令看下是否能够发现设备。更多操作见于另一个维基页

构建 GNU Radio 与 gr-osmosdr

通过上述步骤,就可以操作 bladeRF 板卡了。但是,要想便捷地为 bladeRF 开发软件无线电应用,最好再构建一下 GNU Radio 和 gr-osmosdr。GNU Radio 是一个开源的软件无线电开发平台,提供众多的信号处理模块和简单易用的图形界面开发环境。gr-osmosdr 适配 GNU Radio,为众多硬件板卡(除了 bladeRF 之外还有 HackRF 等)提供一个统一的软件接口。

GNU Radio 依赖比较多,编译安装相对麻烦,一般推荐使用 build-gnuradio 脚本。但是因为其中涉及到从网络下载诸多软件以及编译安装,效率受网速和电脑硬件性能限制,耗时较长。另外,脚本的健壮性不高,所以很容易中途退出。这个脚本很长,但实际上是把整个构建过程划分为几个步骤,放在几个函数里先后执行的。我建议阅读这个 Shell 脚本,每次运行其中的一步或几步,必要时手动完成一些配置。对于新手,这会是一个很好的通过阅读代码学习 Shell 编程的机会。

具体的构建步骤可以在维基或这里找到,这里就不再赘述。只是提几点注意事项:

  • 如果你像我一样,除了 bladeRF 之外,还会使用 Ettus 公司的 USRP 系列设备,那么记得先构建 UHD,然后构建 GNU Radio。
  • build-gnuradio 脚本在 cmake 时,有时用了树外构建,但有时又没用。建议始终用树外构建。
  • 编译 GNU Radio 时,并行 make (make -j N 其中 N 大于 1)时有时会编译失败(竞态条件?),直接 make 就可以正常编译通过,虽然速度会慢很多。什么?make 也会出错?那考虑换一个 git 提交重新编译,并向上游报 BUG 吧。

构建成功 GNU Radio 后,构建 gr-osmosdr 就显得小菜一碟了,标准的 cmake 构建三部曲,项目不大,编译过程也能很快完成。

全部构建完成后,可以使用如下命令用 bladeRF 看一下频谱,检验是否大功告成。其中 FPGA 映像可以从 Nuand 网站下载。此外,最新固件也可以从官网下载。

osmocom_fft -a bladerf=0,fpga=<your FPGA image> -s 2000000 -f 446000000

致谢

本工作由星天科技赞助。

Fedora 上可插拔设备授权:向 plugdev 群组说不

最近,我发现 Fedora 系统上没有 plugdev 群组,而是使用动态 ACL 的方式允许普通用户访问可插拔设备等。

事情的缘由是我在折腾软件无线电 (SDR),更特别的说就是 bladeRF,它在编译安装时会自动安装相应的 udev 规则,以使得普通用户可以访问这块板卡。它提供的 udev 规则文件为 /etc/udev/rules.d/88-nuand.rules,内容如下:

# nuand bladeRF
ATTR{idVendor}=="1d50", ATTR{idProduct}=="6066", MODE="660", GROUP="plugdev"

# Reserved for future bladeRF-specific bootloader
ATTR{idVendor}=="1d50", ATTR{idProduct}=="6081", MODE="660", GROUP="plugdev"

# Cypress Bootloader
ATTR{idVendor}=="04b4", ATTR{idProduct}=="00f3", MODE="660", GROUP="plugdev"

其含义是将 bladeRF (以及相关设备)的权限设为仅属主和群组可读写,群组设为 plugdev。类似的使用 plugdev 群组的 udev 规则设置,在许多涉及可插拔外设的上游项目里都会看到。

然而事实上 Fedora 系统上是没有 plugdev 群组的。bladeRF 维基建议手动建立该群组,并将当前用户添加进去。 但这种做法其实是不被 Fedora 推荐的,原因是这种静态的设备管理群组

  • 不安全。考虑这样的一个场景:一个 SSH 远程登录的用户可以访问物理主机的摄像头、麦克风,只要他是该群组的成员。
  • 不灵活。需要手动地维护该群组的成员列表,新增用户还需要注销当前会话重启会话才能使用该设备。
  • 不具体。plugdev 群组的用户可以使用任何可插拔设备,不论这个设备是手机、摄像头还是麦克风。

Fedora 支持动态的权限控制 (ACL),可以根据用户会话状态、物理座位(seat)配置来决定是否授权设备。在这种机制下,udev 规则文件可以是简单的一行

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", 
  ATTRS{idVendor}=="1ed8", ATTRS{idProduct}=="000[456]" 
  ENV{ID_<some_name>}="1"

这里的 ID_<some_name> 是设备的一个“合适”的类别,例如 ID_CDROM, ID_MEDIA_PLAYER 等。它会出现在 Systemd 的 uaccess 规则文件 70-uaccess.rules 中,这个文件会授权此类设备给活跃用户。

遗憾的是,目前 uaccess 规则文件里并没有一个软件无线电有关的设备类别。所以暂时只能像如下的 udev 规则文件中那样,直接给设备加上 uaccess 的标签:

SUBSYSTEM!="usb", GOTO="nuand_rules_end"
ACTION!="add", GOTO="nuand_rules_end"

ATTR{idVendor}=="1d50", ATTR{idProduct}=="6066", TAG+="uaccess"

# Reserved for future bladeRF-specific bootloader
ATTR{idVendor}=="1d50", ATTR{idProduct}=="6081", TAG+="uaccess"

# Cypress Bootloader
ATTR{idVendor}=="04b4", ATTR{idProduct}=="00f3", TAG+="uaccess"

LABEL="nuand_rules_end"

注意 udev 规则文件命名时开头的数字编号需要小于 70,此时 uaccess 才会生效。如果设备已经连接到电脑上,要使新添加的或新修改的规则生效,还需要 udevadm trigger 一下。

事实上,邮件列表并不推荐上述做法,udev 与 Systemd 开发者 Kay Sievers 表示设备规则文件不应该直接设置 uaccess 这一标签。我已经在 systemd-devel 邮件列表上请求添加一个软件无线电相关的设备类别,得到了肯定的回应,并最终在这次提交中添加了 ID_SOFTWARE_RADIO。在不远的将来,带有这一改动的 Systemd 进入主流发行版后,我们将可以通过在 udev 规则文件中使用类似 ENV{ID_SOFTWARE_RADIO}="bladerf" 的语句,让普通用户以一种更安全灵活的方式使用软件无线电外设。

FUDCon APAC 2014 Day 2

This is my own (unofficial) report of FUDCon APAC 2014 Day 2 (Sunday).

Main Hall

The hosts in the main hall on Sunday were Tobi from GNOME and Tommy He from Fedora. The sessions began with the keynote speech on Systemd by Lennart Poettering. He talked about what is the modern Linux system and what role Systemd plays in it. Pity I didn’t finish listening to the talk, since I was asked out to help with hacking room. It turns out quite a few guys would like a separate hacking room. So we decided to open up Room 2 for hacking. Shortly after setting it up, the most important guest, Richard Stallman (RMS), came to the venue along with Zeuux guys and others. They were not happy with the booth setup (it was the last booth) until an exchange was made. They brought many swags, and some of them are to be sold rather than given away. Richard also went into the hack room since it was still some time from his keynote.

IMG_8876

After Lennart’s talk there were four lightning talks. It’s such a pity that I missed them all, in particular biergaizi’s lightning talk on “Tips about Linux Servers”. Then RMS’s keynote on “Computing, Freedom and Privacy” began. Many more people were coming and filling up the main hall. RMS’s talk itself is not quite new to me since I had listened to him in Tsinghua. The part about why GNOME was created at all was new, but the history was already familiar to Linux hobbyists. However, being able to listen to his talk on site was quite impressive and educating. I have the feeling that his opinion might be ahead of the time but is always right. In the middle of the talk, he held an auction for a toy gnu and “an adorable book” (Free Software, Free Society). After the talk was the Q&A, which lasted till about 12:45. We went to Heyi Building for lunch after that.

IMG_9006

At lunch I got the message from zsun that Ankur would like to have the GPG key signing party in a small room rather than main hall. That was doable and we had difficulties to find a substitute to fill in the empty slot in main hall. At last the signing party was held in Room 2 and there was no replacement in main hall.

Room 3

After lunch it was near 14:00, and the first talk in Room 3 was supposed to be mine. So I hurried there to prepare. The volunteers (Feng Tian, Justin Wong, Rosie Ye, Tang Zhixin, etc.) were ready. I began my talk on LaTeX Tips a little bit later than the schedule. I talked about common compilation errors and output errors and how to fix them. The time was limited so I skipped the part about math formulas and BibTeX errors. I got a question about the main advantages of LaTeX compared with GUI Office applications. I explained that the advantages lie in high quality output and automatic generation of table-of-contents and list-of-various-stuff. Users normally only focus on the main contents rather than formatting issues.

The second talk was “CD using Docker” by Gerard Braad. He explained the actual definition of CD, Consistent Development and Deployment, and use Docker to demonstrate the concept. He introduced PaaS, LXC, cgroups, Dokku and so on along the talk. The talk was presented in an interactive and interesting way: questions, answers, and gifts!

After that there were only 10 minutes for tea break. However it was a nice time to take photos in front of the large banner. The following talk was meant to be Carbo Kuo’s Batsh topic, but he could not come and had sent regrets on Saturday. So Cheer Xiao’s talk was moved upwards to fill in the slot. Cheer Xiao talked about his experiments with Elvish, a new Unix shell created by himself. There were many considerations and tradeoffs when designing a shell, and he introduced the philosophy behind his choices. He also compared it with existing shells such as fish and zsh.

There was no more talks in Room 3 afterwards, so we headed for Room 8 to join the discussion about Fedora Women.

Room 8

The last talk in Room 8 was “Fedora Women” by Nitesh. He would like to make it more an interactive discussion than an oral presentation, and asked zsun and me to help translate. The session turned out to be quite productive. There were many nice suggestions out of the discussion. The main points are summarized as follows (with relevant names in parentheses):

  • For online communications such as IRC in a diverse community like Fedora, people generally do not know whether one is a man or woman, so there is normally no discrimination against gender. The community is equal to men and women. Potential women contributors should not fear questions such as why do you code you are a girl. If there is any such question, it is more important what is one’s interest than what is others’ opinion. (Nitesh, Ankur, Feng Tian)

  • Fedora has many roles and tasks for contributors. Even if you do not like coding, you can try to join the design team or the translation (L10N) team or others to contribute. Fedora also has a lot of special interest groups (SIGs) which welcomes people with that special interest, such as electronics, cloud computing and so on. And there is the opportunity to start a new SIG. There is a SIG called Fedora Join SIG, which is an ideal place for people who are new to the project and do not know what exactly they should do. You can just do informal introduction in the Join SIG mailing list and people will help you find what you can do. (Jaroslav, Aditya, Nitesh, Ankur)

  • There are many tasks waiting for people to join and contribute. And there will be many new tasks since Fedora.next is coming. Some of them are easyfix ones, which is very suitable for new contributors to get started. (Ankur, Jaroslav)

  • The local communities should draw the attention of outside non-users, organize activities to help them especially women to install Fedora on their computer and to show them how things work in the communities. Among the activities some can be girls oriented. Besides, blogging about how to install the OS and how to do various things on Fedora! (Martin, Aditya, Nitesh)

  • Lovely dolls attract girls! We should design more stuff than stickers for offline events. (Feng Tian, zsun)

  • Fedora might have a narrower user base than other projects like GNOME. But people can actually contribute to Fedora even without using it everyday. The way can be bug reporting, translating, or volunteering in offline events, etc. (Justin Wong, zsun)

  • A question to current contributors: why do you fail to bring your girlfriend to the community? (Robin Lee)

  • We should continue the discussion after the conference, rather than raising the same question again on the next conference. We should setup activities talking about how to achieve something, especially in Beijing. We should have clear targets. (Martin)

Closing

We went back to the main hall for the closing part of the event, and found the last talk in the main hall had not been finished, and it also became a discussion. So it seems we should consider panel discussion as a session type in the future.

The closing speech was given by Kat (IIRC) and Jaroslav respectively, and then followed by the speech by the local team. Emily and I went on the stage. She spoke in English and I did the translation. We gave our thanks to everyone, especially hardworking volunteers. The two hand fans, full of writings in different languages, were given to Tong Hui and Zamir Sun respectively as gifts for best volunteer of each community. The top horizontal scroll for the couplet was decided to be “Happy Hacking” according to the result of two days’ voting. At last we had a group photo.

SAM_4563.JPG

SAM_4575.JPG

Evening

In the evening we had a very nice buffet dinner at Oasis Café, Vision Hotel, which is just behind the conference venue. We toasted to everyone and thanked them for coming. I sat with robyduck and zsun. We talked about a lot of things including robyduck’s travel plan. Robyduck also pointed out a possible issue with FZUG’s logo. Richard Stallman also went to the celebration party. Besides, zsun and I stood in front of the camera of Nitesh near the cafe since we promised to participate the short interview by him and Ankur. It was such a relax at the dinner after two days’ event and after several months’ preparation. And I was really happy that many people found the event good and successful.

FUDCon APAC 2014 Day 1

This is my own (unofficial) report of FUDCon APAC 2014 Day 1 (Saturday).

Registration

Tonghui and I went up early, had a simple breakfast at the hotel, and then went to the venue. I took the Live DVDs along, and the box was kind of heavy (about 400 DVDs!). Many volunteers were already there and ready when we arrived. Christopher was there too and needed to find a hotel for the night. Robin Lee offered him help. I took out about 50 DVDs and put them at the Fedora booth, and told the volunteers at registration desks to distribute the remaining ones. I took out some and put them close to the desks while left others in the box. It turned out to be not so good since the ones in the box were left unnoticed by the volunteers and were not distributed. But they can be used in future events anyway. It rained at night, so we expect fewer attendees than usual. Later in the night I got the message there was above 200 registrants on Saturday, which is a pretty good number.

As for the swags (gifts) for attendees, we prepared sufficient conference bags and badges, and each bag had a Fedora flyer, a Fedora DVD, a Deepin DVD, and some flyers from various sponsors. It was good except several issues. The paper of Fedora flyer is soft (157g paper) and the bag is soft (basketball bag or so), which makes the flyer easily rumpled. Another issue is that the Deepin DVD was not together with Deepin brochure.

Although we had enough bags, there were not sufficient T-shirts. We had decided to provide each volunteer two T-shirts, one from GNOME and one from Fedora. Also we need to reserve T-shirts for designers, speakers and donate tickets buyers. Therefore not many T-shirts were left for normal attendees, so they had to be distributed in a first-come, first-served manner.

Main Hall

The sessions at main hall began with loud sound of a Chinese gong. The hosts are Max from GNOME and Gerard (gbraad) from Fedora. Kat and Jaroslav gave the welcome speech from each side respectively. Then Emily represented the local team and introduced the event and also called for voting for the top horizontal scroll for the couplet — Evolution of the Desktop, Innovation for the Community — which is the conference theme. The former of the two parts was proposed by GNOME folks. It took some time for me and other Fedora guys to think of the latter half.

IMG_8948

Then it was the time for keynote speeches. First Tobi gave a nice overview of GNOME 3.12 features. Then Jiri and Jaroslav introduced Fedora.next to the audience, talking about the features and the community. Pity I didn’t finish listening to their talk, since I needed to head to Room 8 to prepare following Fedora sessions. One of the most important thing was to bring a Fedora Friend Finder (power strip) there!

Room 8

When I arrived at Room 8, the volunteers (Shi Jie, Ma jing, Fan Jiayue and others) were already there. Shi Jie was the host of Room 8 on Saturday. His introduction scripts were outdated and could not reflect real schedule that day, but he adjusted quickly with the help of kraks. Ma Jing was the coordinator in that room, and was in charge of distributing gifts (books and cups) to questioners. Fan Jiayue was responsible for posting news on SNS websites (weibo) and preparing the daily news report.

The first speech was “Fedora Videos” by Nitesh Narayan Lal. He talked about one main current work is to organize all the videos. It is worth pointing out Nitesh (together with Ankur) was also responsible for recoding short videos of interview with random attendees.

Then Robert Mayr from Italy gave us the talk “Fedora Websites – present and future”. The talk was quite interesting and the new design for Fedora.next was quite impressive. Currently there are no APAC contributors for Websites subproject. Hopefully we will have interested APAC folks join the team. Robert also showed the easyfix page and Tommy asked about the feasibility of localizing it.

The morning sessions ended after that, and then we went to lunch at Heyi Building in Beihang. I met Nitesh and Aditya there, and helped them to tell the cook they need vegan food. There was a short period when no one was taking care of the booth. Zamir helped and I asked dongfengweixiao to be there quickly.

At 14:00 the afternoon session started. First Aditya Patawari from India talked about “Orchestration with Ansible at Fedora Project.” He is from the infra team, and he talked about why they moved to Ansible, and how to use Ansible to executive ad hoc commands and create playbooks.

Then Zamir Sun brought a brief introduction to FirewallD. He introduced the advantage of FirewallD, the GUI and command line interface of FirewallD, and the rich language to define complex rules. He also called for help on localization of FirewallD wiki pages and software applications.

Then it was a tea break. Unfortunately there was no drinkable tea since (we thought) there was no hot spoiled water at the venue. But the registration desks were moved to the side and the large banner stood out, which became a very good background to take photos. The booth was also quite popular, partially due to the lovely chameleon dolls brought by SUSE. I also met Su Zhe, the author of venerable SCIM, by the introduction of Emily at the booth. Su Zhe shared some information about Google’s input method project, and told that they are planning to release the input method framework open source.

After the break I went to the main hall to listen to Peng Wu’s “Wayland intro with i18n hacks”. I came in a bit late and only caught the part of two patches for wayland and a demo to run wayland for debugging. Su Zhe raised questions difficult to answer about Wayland and Mir.

After that I went back to Room 8 for Ankur Sinha’s hackfest about “ROS on Fedora”. Ankur introduced ROS and Fedora packaging. The talk was finished early but there was not much time for hacking. Ankur planned hacking on the next day. So we had more discussions, including Fedora Join SIG.

Then all the sessions for Room 8 on Saturday ended. We volunteers, speakers, and some attendees took a group photo, and then went back to the main hall.

IMG_8834

Note: Ankur’s report contains more photos!

Main Hall Again

In the main hall we had three lightning talks, and they were Deepin Desktop Environment (DDE) from Xia Bin, Chandao FIXME from Wang chunsheng, and Open Build Service (OBS) from Lance Wang. Then we reached the closing part of first day. A wonderful video of short interviews was created by the volunteers and presented. We also had volunteers take a group photo.

DSC03705

Evening

I originally intended to join the sports game after the one day’s sessions, but at that time I was with tiansworld, tommy, and Wang Ye. I needed to help tiansworld to check in at the hotel, but we decided to have dinner first. We searched around the street outside East Gate of Beihang, and settled at Hannashan eating Korean toast. The food was good and not so expensive with groupon. But it would be not so good without conversation! We talked a lot, and after the dinner, Wang Ye left but liangsuilong joined the conversation at McDonald’s. We talked about all kinds of stuff, Fedora related or not. The conversation lasted to over 11:00 PM until I got a message from tonghui, asking whether I was back. We agreed it was a bit late, and it was time to say goodbye and go for rest.

When tiansworld and I were back at the hotel, I helped with the check-in at the front desk. Most of the staff there are not proficient with English, and zsun had reminded me that we needed to speak of 亚洲峰会 (Chinese for Asia Summit) to let them know which group we belonged to. After it was done, we went upstairs to each one’s room. Finally I had time to revise my slides for Sunday. Check the git log if you want to know the detailed changes. While I was preparing the slides, tonghui was checking the photos taken in the day. There are many good photos to tell the truth! It was quite late in the night after I finished my slides, so I went sleep quickly.

FUDCon APAC 2014 Day 0

This is my own (unofficial) report of FUDCon APAC 2014 Day 0 (Friday).

Preparation

There were no speech sessions for FUDCon on Friday, so it was all about event preparation in the day. At around 11:00 AM, I called Justin Wong, another guy from TUNA, also a volunteer of host, to help me move event gifts in my lab downstairs, where Emily waited for us with her car. We went to the venue, New Main Building in Beihang University, on the car full with sponsored gifts, including but not limited to cafe cups, hats, DVDs, books. Dongfengweixiao also just arrived when we got there. We had a brief lunch together at PengLaoShi, a Chinese fast food restaurant.

On the way back to the venue after lunch, we ordered the bottled drinking water for the three days. In the afternoon we are busy with setting up everything. Zamir (zsun) arrived to help. First we set up the booth with the desks rent from venue as well as desks from Beihang leagues (credit Wang Yang). The shop owner of bottle water helped with moving the desks from outside to venue. We had a booth for Fedora too, which dongfengweixiao took care of, so we left some Fedora flyers (and later on many stickers, F20 Live DVDs) there. We met one guy in orange T-shirt while setting up the booth. He asked about the place for upcoming GNOME training sessions. The next day I knew it was Tobi, the host in main hall from GNOME side!

Tong Hui (tonghui) arrived later and then event roll-up posters, X posters, and vertical banners arrived. I helped to hang up the two vertical banners in the main hall with tonghui and dongfengweixiao. It took three up-and-downs to finally make them look good (symmetric and smooth). Next I helped to buy some utilities such as power strips, mark pens, glue, and “postit” sticky notes. I also fetched the express of stickers. After I came back, many sponsors were there. There were some disagreements with booth position, but they were solved later. Li Bin (libin) and many other volunteers also arrived, and the registration desks (sign-in office) was set up. They put various small gifts into conference bags. T-shirts arrived and classified. Large banner which sat on the ground arrived a bit late, but was put up quickly. Time went by without being noticed, and it was almost 7 o’clock when we headed for the FUDPub, i.e. the welcome party.

FUDPub (Welcome Party)

The FUDPub was at Sculpture in Time Cafe, a cafe bar on campus and quite near to the venue. It was scheduled to begin from 6:00 PM, and we had volunteers waiting there to help from that time. As mentioned above some volunteers and I arrived a little late, and there were few empty seats then. Some early birds already begin to drink beer when we started to order pizzas and noodles! Around 60 people from the event were there, and the cafe bar seemed to be not able to handle so many people. The service was slow and a bit chaotic, but luckily we had sunny (and later on libin) who took care of the detailed list of ordered and served food. Except the long waiting time for food, it was good. I met and said hello to Ankur, Nitesh and other guys. Max called on emily, libin and me to toast to everyone. Ankur asked to continue discussion at the hotel after the party, but I stayed till 10:00 PM at the cafe bar since tonghui had so many interesting stories to tell! While we went to the hotel, I picked up the Fedora 20 Live DVDs with GNOME Desktop, whose creation was finished late due to some issues with DVD sleeves during production.

Hotel

The conference hotel is Beihang Training Center, which is inside Beihang and near to the conference venue. There was no WiFi at hotel, only one wired interface available. Luckily tonghui set up a WiFi AP using his laptop with GNOME 3.12. He also charged his camera for next days’ activities. I replied some emails, took a shower, and then went to bed. I had planned to revise my slides, but it had to be delayed to Saturday.

Fedora Activity Day China 2014 Report

Fedora Activity Day (FAD) China 2014 was successfully held at Park Plaza of Beijing Science Park, Beijing on Mar 30 (Sunday). It was organized by Fedora Zhongwen User Group with the help of CSDN. It was under the umbrella of Open Source Technology Conference (OSTC) 2014 initiated by CSDN, being one of three parallel sessions in the afternoon. There were around 600 attendees in total, and about 200 in the FAD session.

I arrived at the venue in the morning with more than 100 Live DVDs and 500 stickers. We distributed them during the Red Hat booth as well as the afternoon session. In the morning there were several keynote speeches and one panel discussion. More details can be found in the CSDN news report.

The afternoon session began at 1:30 pm. Thomas Yao and I served as the hosts of FAD. The first talk was “About Those Python Asynchronous Concurrency Frameworks” by Fantix King, CTO at FlowForge Games, Archlinux x32 committer, and Python programmer. He introduced the concept of concurrency, compared Tornado, Twisted, and Gevent, and then introduced asyncio, the newly available framework in Python 3.4.0.

Python Concurrency Frameworks by Fantix King

Python Concurrency Frameworks by Fantix King

The second talk was “Use Linux Command Line as a Hacker” by Xiaodong Xu (Toy), the webmaster of LinuxToy. He shared a lot of command line tips to fix typos, manipulate shell history, and speed up operations. In the QA session he talked about his opinion on text editor choice and Linux distro choice.

Toy

Toy

The next talk was “Reform the Toolbox: From Open Source Software to Open Source Service” by Daobing Li, the chief architect of Qiniu, who is also a Debian developer. He talked about the achievements of open source cloud service, and shared his vision of future cloud service – cloud in computer room. He also gave suggestions on how developers treat cloud services.

Daobing Li

Daobing Li

Following the talk was “Introduction to HackRF & GNURadio” by Scateu Wang, the creator of hackrf.net and the former leader of TUNA. He demonstrated the ease of using GNU Radio to develop software defined radio applications for DTMF decoding, FM modulation and demodulation, digital audio broadcasting, etc. He also introduced HackRF, the newly created inexpensive hardware peripheral used with GNU Radio.

Scateu Wang

Scateu Wang

The next talk was “Fedora Ambassadors & FUDCon” by myself. I introduced the four foundations of Fedora Project, gave an overview of Fedora Ambassadors project, showed what ambassadors do and how reimbursement works, and then shared the recent progress of organizing FUDCon APAC 2014 to be held in May and welcomed everyone to join.

Alick

Alick

Next Emily Chen, GNOME.Asia founder, senior software engineer in Oracle, gave the talk “Bringing More Women to Free and Open Source Software”. She introduced the Outreach Program for Women initiated by GNOME, talked about how it increases the women participation in open source projects. The annual program provides prize for women participants in similar way with GSoC, but it does not require the applicants to be students, and applicants does not need to write code in the program.

Emily Chen

Emily Chen

The following talk was “Operation and Management of SHLUG” by Thomas Yao, leader of Shanghai Linux User Group (SHLUG), founder of GitCafe.com. Thomas gave an impressive speech without any slides. He talked about the history of SHLUG and shared the experience. He pointed out the pioneering effort of building the first open source mirror site in China, Geekbone, and the importance of keeping the community focus on technique rather than commercial activities. He also shared the interesting stories of Hacking Thursday and Rails Girls.

Thomas Yao

Thomas Yao

After that is the panel discussion on “History and Future of Open Source OS in China”. It was moderated by Thomas Yao, and the panelists are Weijia He from Redflag College of Education, Jianzhong Huang from Redflag R&D, Jack Yu from UbuntuKylin, and Yong Wang from Linux Deepin. They shared their opinions and experiences about Linux Desktop, collaboration of distros, cultivation of open source talents, and open source in education.

Panel Discussion

Panel Discussion

At last, Martin, leader of Beijing Linux User Group (BLUG) gave a lightining speech of introducing BLUG and its activities. Everyone is welcomed and should not worry about their English since there are actually many Chinese there. And it is quite easy to join the event by registering on BLUG website or joining discussion in mailing list.

At night there is the Open Source Night, a social event for free face-to-face discussions. Unfortunately I didn’t attend it. I had dinner with FUDCon and GNOME.Asia organizers and discussed current progress and following tasks.

Overall it is a very good event in my mind. If I have to point out some issues, I’d say there might be too many talks and no time for tea or coffee in between! Besides, my own talk was prepared in a bit hurry, and not practised well beforehand.

The slides links is available on CSDN news. They also provide a Chinese report for FAD. There is a great minute for the meeting by Bojie Li from USTC LUG. The videos and various other materials can be found at this link.